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

webstorm #55

Closed
duncup opened this issue Dec 29, 2019 · 4 comments
Closed

webstorm #55

duncup opened this issue Dec 29, 2019 · 4 comments

Comments

@duncup
Copy link

duncup commented Dec 29, 2019

我试了下这个,发现在 webstorm 中始终无法跳转到 service 下的方法上。在 vs code 里是可用的。想请教下是我姿势不对还是确实和 webstrom 的提示不兼容。

@whxaxes
Copy link
Member

whxaxes commented Jan 2, 2020

这个跟 egg-ts-helper 无关,跟 egg 里的声明有关,egg 的声明方式( declare module 'egg' )在 webstorm 下识别似乎有 bug ,目前还没找到解法

@duncup
Copy link
Author

duncup commented Jan 2, 2020

3q

@zhangciwu
Copy link

我的解决方法:添加一个app/index.d.ts,内容如下

import {BaseContextClass, Context, IService} from 'egg';
import 'egg'; // Make sure ts to import egg declaration at first


declare module 'egg' {
  export interface Context {
    service: IService;
  }


  export interface IService {
  }


  export class BaseContextClass {
    public ctx: Context;
  }
}

这样webstorm就可以识别出来了

@whxaxes
Copy link
Member

whxaxes commented Mar 5, 2020

@duncup 有空的话,帮忙验证一下上面那种做法?我这边没有 webstorm 的 license 了 ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants