From d7c858f68be01b276ba59d01263e3d5f53afd118 Mon Sep 17 00:00:00 2001 From: Dave Wasmer Date: Thu, 24 May 2018 09:29:31 -0600 Subject: [PATCH 1/3] Remove Context index signature --- types/koa/index.d.ts | 2 -- 1 file changed, 2 deletions(-) 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 { From 4ba9fb918f20ad92dc42751d4724c1249dc04ff4 Mon Sep 17 00:00:00 2001 From: Dave Wasmer Date: Thu, 24 May 2018 11:30:02 -0600 Subject: [PATCH 2/3] Add module augmentation to tests --- types/koa/koa-tests.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/types/koa/koa-tests.ts b/types/koa/koa-tests.ts index ea0a4a18b8..2eff16857a 100644 --- a/types/koa/koa-tests.ts +++ b/types/koa/koa-tests.ts @@ -1,5 +1,11 @@ import Koa = require("koa"); +declare module 'koa' { + export interface Context { + db(): void; + } +} + const app = new Koa(); app.context.db = () => {}; From e711b702bfbc0f080992ca3d452883fe56c65388 Mon Sep 17 00:00:00 2001 From: Dave Wasmer Date: Thu, 24 May 2018 13:24:24 -0600 Subject: [PATCH 3/3] Add tests for BaseContext as well as Context --- types/koa/koa-tests.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/types/koa/koa-tests.ts b/types/koa/koa-tests.ts index 2eff16857a..2ddf9b41e2 100644 --- a/types/koa/koa-tests.ts +++ b/types/koa/koa-tests.ts @@ -1,9 +1,12 @@ import Koa = require("koa"); declare module 'koa' { - export interface Context { + export interface BaseContext { db(): void; } + export interface Context { + user: {}; + } } const app = new Koa(); @@ -12,6 +15,7 @@ app.context.db = () => {}; app.use(async ctx => { console.log(ctx.db); + ctx.user = {}; }); app.use((ctx, next) => {