Typescript Extend Third-party Declaration Files
How can I extend third-party declaration files? for example, I want to extend Context from @types/koa and add an extra field(resource) to it. I tried this: // global.d.ts declare n
Solution 1:
You have to use module augmentation as described here:
import { Context } from "koa";
declare module "koa" {
interface Context {
resource: any;
}
}
Post a Comment for "Typescript Extend Third-party Declaration Files"