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

feat: hack support for webstorm(intellij) #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
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
Author

Choose a reason for hiding this comment

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

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

Copy link
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
Author

Choose a reason for hiding this comment

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

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

Copy link
Member

Choose a reason for hiding this comment

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

好,我待会验证一下

Choose a reason for hiding this comment

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

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

}
}`,
};
}