WebStorm-参数类型{providedIn:"root"}不可分配给参数类型{providedIn:Type< any>. | “根" | null}&可注射提供者 [英] WebStorm - Argument type {providedIn: "root"} is not assignable to parameter type {providedIn: Type<any> | "root" | null} & InjectableProvider

查看:307
本文介绍了WebStorm-参数类型{providedIn:"root"}不可分配给参数类型{providedIn:Type< any>. | “根" | null}&可注射提供者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将应用程序从Angular v5迁移到v6,并且在尝试在提供程序中指定providedIn时遇到以下打字错误:

I'm trying to migrate my app from Angular v5 to v6 and I face the following typescript error while trying to specify providedIn in my providers

不可将参数类型{providedIn:"root"}分配给参数类型{providedIn:Type | 根" | null}& InjectableProvider

Argument type {providedIn: "root"} is not assignable to parameter type {providedIn: Type | "root" | null} & InjectableProvider

 @Injectable({
    providedIn: 'root',
 })
 export class MyService {
 }

我复制并粘贴了Angular文档中的代码 https://angular.io/guide/dependency-注射

I copied and pasted the code from the Angular doc https://angular.io/guide/dependency-injection

有什么主意吗?

更新

我创建了一个空白项目ng new ...,并添加了一个提供程序ng g service my-new-service,在WebStorm中打开了该项目,一切正常,我没有遇到任何与该虚拟项目有关的错误

I have created a blank project ng new ... and added a provider ng g service my-new-service, opened the project in WebStorm and everything was ok, I didn't face any error with that dummy project

更新

我联系了WebStorm支持,事实证明这是WebStorm的已知错误 https://youtrack.jetbrains.com/issue/WEB-32634

I contacted the WebStorm support, it turns out that this is a known bug of WebStorm https://youtrack.jetbrains.com/issue/WEB-32634

更新

Webstorm 2018.1.4(尚未发布)应解决此问题,请参见 https://youtrack .jetbrains.com/issue/WEB-32634

Webstorm 2018.1.4 (not yet released) should fix the issue, see https://youtrack.jetbrains.com/issue/WEB-32634

更新

Webstorm团队将修复程序移至2018.1.5

Webstorm team moved the fix to 2018.1.5

更新

2018年6月17日(星期日),Webstorm修复程序已发布

Sunday 17th June 2018, the Webstorm fix has been released

推荐答案

信不信由你,我在Webstorm中关闭并打开了我的项目,错误刚刚消失了

Believe me or not, I closed and opened my project in Webstorm and the error just disappeared

感谢@yurzui和@AdrianFâciu的支持

Thx @yurzui and @AdrianFâciu for the support

更新

事实证明,这是Webstorm中的一个已确认错误,后来在v2018.1.5中得到了纠正,并于2018年8月17日星期日发布.我已将编辑器更新为该版本,不再遇到问题了.

It turns out it was a confirmed bug in Webstorm which was later corrected in v2018.1.5 and published Sunday 17th August 2018. I have updated my editor to this version and didn't face the problem anymore

Webstorm问题跟踪程序: https://youtrack.jetbrains.com/issue/WEB-32634

Webstorm issue tracker: https://youtrack.jetbrains.com/issue/WEB-32634

v2018.1.5发行说明: https://confluence. jetbrains.com/display/WI/WebStorm+181.5281.31+Release+Notes

v2018.1.5 release notes: https://confluence.jetbrains.com/display/WI/WebStorm+181.5281.31+Release+Notes

这篇关于WebStorm-参数类型{providedIn:"root"}不可分配给参数类型{providedIn:Type< any>. | “根" | null}&可注射提供者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆