You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import { Context, Service } from 'egg'
export default class ApplicationService extends Service {
getData () {
return 'hello world'
}
}
自动生成的typing文件如下: typing/app/service/index.d.ts
import'egg';// Make sure ts to import egg declaration at firstimportApplicationfrom'../../../app/service/application';declaremodule'egg'{interfaceIService{
application: Application;// 这里的Application会被只想到egg下的Application,不能正确解析}}
import'egg';// Make sure ts to import egg declaration at firstimportPrefixApplicationfrom'../../../app/service/application';declaremodule'egg'{interfaceIService{
application: PrefixApplication;// 生成的prefix}}
这样处理完之后就可以正确解析了。
The text was updated successfully, but these errors were encountered:
假设在service目录下有一个文件为
service/application.ts
自动生成的typing文件如下:
typing/app/service/index.d.ts
如果此时在controller中访问
ctx.service.application.getData()
,getData
这个方法并没有真正的被解析道ctx.service.application
对象上。个人的建议能否在生成的时候添加prefix配置,使得生成的typing文件如下
typing/app/service/index.d.ts
这样处理完之后就可以正确解析了。
The text was updated successfully, but these errors were encountered: