Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add comments for re-writing properties from Koa #3332

Merged
merged 1 commit into from Dec 20, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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