angular - WebStorm - 参数类型 {providedIn : "root"} is not assignable to parameter type {providedIn: Type<any> | "root" | null} & InjectableProvider

标签 angular typescript webstorm angular6

我正在尝试将我的应用程序从 Angular v5 迁移到 v6,但在尝试在我的提供程序中指定 providedIn 时遇到以下 typescript 错误

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-injection

有什么想法吗?

更新

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

更新

我联系了 WebStorm 支持,原来这是 WebStorm 的一个已知错误 https://youtrack.jetbrains.com/issue/WEB-32634

更新

Webstorm 2018.1.4(尚未发布)应该可以解决这个问题,请参阅 https://youtrack.jetbrains.com/issue/WEB-32634

更新

Webstorm 团队将修复移至 2018.1.5

更新

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

最佳答案

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

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

更新

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

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

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

关于angular - WebStorm - 参数类型 {providedIn : "root"} is not assignable to parameter type {providedIn: Type<any> | "root" | null} & InjectableProvider,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50201189/

相关文章:

angular - p-文件上传 : how to read file after upload

javascript - 以 Angular 获取模态组件中的路由参数

Angular 6 : View is not updated when Subscribe method is called

javascript - 需要解决方法以使 WebStorm 的自动完成功能能够解析第三方模块方法

javascript - 如何在 PhpStorm 中 bundle JavaScript 文件

javascript - Angular 2 - 在数组中上传文件

angular - 以 Angular 发送 Action 的正确方法是什么?

javascript - Typescript 验证器模式正则表达式在 Internet Explorer 中出现意外量词错误,但在 Google Chrome 中有效

typescript - TypeScript 中的联合类型有什么用?

webstorm - 为什么会出现 `binary operation argument type newval is not compatible with type string`