Skip to content
Open
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
9 changes: 8 additions & 1 deletion src/generators/egg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ export default function(config: TsGenConfig, baseConfig: TsHelperConfig) {
return {
dist: path.resolve(config.dtsDir, 'index.d.ts'),
content:
`import { Context, IService } from '${baseConfig.framework}';\n` +
`export * from '${baseConfig.framework}';\n` +
'export as namespace Egg;\n',
'export as namespace Egg;\n\n' +
`\/\/ hack support for webstorm (intellij)
declare module 'egg' {
export interface Context {
service: IService;
Copy link
Copy Markdown
Member

@whxaxes whxaxes Feb 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样不会导致 ctx 只有一个 service 属性么 ...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

多次定义一个interface是追加,不是覆盖

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我知道这是追加,但是 webstorm 不是识别不到 egg 的声明么,那这样新加个声明它就可以识别到了?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

对,就是这么神奇…… 我已经在本地测试过

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好,我待会验证一下

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

大佬能教我操作一下吗, 我也是碰到了webstorm下egg方法跳转不了的问题

}
}`,
};
}