diff --git a/types/koa/index.d.ts b/types/koa/index.d.ts index 07ddadc0c8..ea6bd60a46 100644 --- a/types/koa/index.d.ts +++ b/types/koa/index.d.ts @@ -659,8 +659,6 @@ declare namespace Application { * Default error handling. */ onerror(err: Error): void; - - [key: string]: any; } interface Request extends BaseRequest { diff --git a/types/koa/koa-tests.ts b/types/koa/koa-tests.ts index ea0a4a18b8..2ddf9b41e2 100644 --- a/types/koa/koa-tests.ts +++ b/types/koa/koa-tests.ts @@ -1,11 +1,21 @@ import Koa = require("koa"); +declare module 'koa' { + export interface BaseContext { + db(): void; + } + export interface Context { + user: {}; + } +} + const app = new Koa(); app.context.db = () => {}; app.use(async ctx => { console.log(ctx.db); + ctx.user = {}; }); app.use((ctx, next) => {