WebStorm - Argument type {providedIn: “root”} is n

2019-02-11 14:02发布

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

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

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

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

Any idea?

UPDATE

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

UPDATE

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

UPDATE

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

UPDATE

Webstorm team moved the fix to 2018.1.5

UPDATE

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

1条回答
对你真心纯属浪费
2楼-- · 2019-02-11 14:04

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

Thx @yurzui and @AdrianFâciu for the support

UPDATE

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 issue tracker: https://youtrack.jetbrains.com/issue/WEB-32634

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

查看更多
登录 后发表回答