typescript - 覆寫 koa-body 類型定義
我如何覆寫 koa-body 的型別定義?koa-body 有如下的型別定義:
declare module "koa" {
interface Request {
body: any;
}
interface Context {
body: any;
}
}
我想要覆寫成類似這樣的東西(檔案 index.d.ts):
import { Files } from 'formidable'
interface IBody {
files: Files
}
declare module "koa" {
interface Request {
body: IBody
}
interface Context {
body: IBody
}
}
但是智能感知不工作,它仍然顯示 ctx.request.body 是 any。我該怎麼做?