Skip to content

Commit

Permalink
fix(d.ts): make app.locals and ctx.locals definitions merging availab…
Browse files Browse the repository at this point in the history
…le (#2546)
  • Loading branch information
tonyke-bot authored and atian25 committed May 15, 2018
1 parent e5d4752 commit e7696a7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ declare module 'egg' {
* ```js
* // config/config.default.ts
* import { EggAppInfo } from 'egg';
*
*
* export default (appInfo: EggAppInfo) => {
* return {
* keys: appInfo.name + '123456',
Expand Down Expand Up @@ -570,7 +570,7 @@ declare module 'egg' {
* global locals for view
* @see Context#locals
*/
locals: any;
locals: IApplicationLocals;

/**
* HTTP get method
Expand Down Expand Up @@ -627,6 +627,8 @@ declare module 'egg' {
runInBackground(scope: (ctx: Context) => void): void;
}

export interface IApplicationLocals extends PlainObject {}

export interface FileStream extends Readable { // tslint:disable-line
fields: any;

Expand Down Expand Up @@ -792,7 +794,7 @@ declare module 'egg' {
*
* @member {Object} Context#locals
*/
locals: any;
locals: IApplicationLocals & IContextLocals;

/**
* alias to {@link locals}, compatible with koa that use this variable
Expand Down Expand Up @@ -875,6 +877,8 @@ declare module 'egg' {
redirect(url: string, alt?: string): void;
}

export interface IContextLocals extends PlainObject {}

export class Controller extends BaseContextClass { }

export class Service extends BaseContextClass { }
Expand Down Expand Up @@ -998,7 +1002,7 @@ declare module 'egg' {
* Powerful Partial, Support adding ? modifier to a mapped property in deep level
* @example
* import { PowerPartial, EggAppConfig } from 'egg';
*
*
* // { view: { defaultEngines: string } } => { view?: { defaultEngines?: string } }
* type EggConfig = PowerPartial<EggAppConfig>
*/
Expand Down

0 comments on commit e7696a7

Please sign in to comment.