Transitioning my app from Angular v5 to v6 has presented me with a TypeScript error when trying to define providedIn
in my providers.
The argument type {providedIn: "root"} cannot be assigned to the parameter type {providedIn: Type | "root" | null} & InjectableProvider
@Injectable({
providedIn: 'root',
})
export class MyService {
}
I simply copied and pasted the code from the Angular documentation https://angular.io/guide/dependency-injection
Any thoughts on how to resolve this?
UPDATE
To troubleshoot, I created a new project using ng new ...
and added a provider using ng g service my-new-service
. Surprisingly, there were no errors when I opened this dummy project in WebStorm
UPDATE
After reaching out to WebStorm support, it appears that this issue is a known bug in WebStorm
UPDATE
It seems that Webstorm 2018.1.4 (which hasn't been released yet) will address this problem, as mentioned here:
UPDATE
The Webstorm team has decided to include the fix in version 2018.1.5
UPDATE
Good news! The Webstorm fix for this issue was released on Sunday, June 17th, 2018