Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebStorm - Argument type {providedIn: "root"} is not assignable to parameter type {providedIn: Type<any> | "root" | null} & InjectableProvider

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

like image 813
David Dal Busco Avatar asked May 06 '18 15:05

David Dal Busco


1 Answers

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

like image 65
David Dal Busco Avatar answered Oct 24 '22 12:10

David Dal Busco