Skip to content

Commit

Permalink
fix: Add comments for re-writing properties from Koa (#3332)
Browse files Browse the repository at this point in the history
  • Loading branch information
Maledong authored and atian25 committed Dec 20, 2018
1 parent f312db7 commit edfe660
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -710,13 +710,20 @@ declare module 'egg' {
* the egg's Context interface, which is wrong here because we have our own
* special properties (e.g: encrypted). So we must remove this property and
* create our own with the same name.
* @see https://github.com/eggjs/egg/pull/2958
*
* However, the latest version of Koa has "[key: string]: any" on the
* context, and there'll be a type error for "keyof koa.Context".
* So we have to directly inherit from "KoaApplication.BaseContext" and
* rewrite all the properties to be compatible with types in Koa.
* @see https://github.com/eggjs/egg/pull/3329
*/
export interface Context extends KoaApplication.BaseContext {
[key: string]: any;

app: Application;

// property of koa.Context
// properties of koa.Context
req: IncomingMessage;
res: ServerResponse;
originalUrl: string;
Expand Down Expand Up @@ -789,8 +796,7 @@ declare module 'egg' {
realStatus: number;

/**
* 设置返回资源对象
* set the ctx.body.data value
* Set the ctx.body.data value
*
* @member {Object} Context#data=
* @example
Expand Down

0 comments on commit edfe660

Please sign in to comment.