WebStorm thinks it is a ternary operator and expects expressions and colon next. Maybe it thinks it is a TS code, while this is JS code in .js file, I'm not sure.
How can I switch this inspection off?
TypeScript compiler service reports the error here because optional chaining is not supported in TypeScript < 3.7. Service is used for JavaScript linting if the service is enabled in Settings | Languages & Frameworks | TypeScript and "allowJs"
is set to true
in tsconfig.json
.
If you only want the service to compile/lint TypeScript, make sure that "allowJs"
is either not set or set to false
in tsconfig.json
I was facing the same issue, then updating webstorm to this verion worked. So simple solution is updating the webstorm version. Make sure you are using typescript version 3.7 or above since optional chaining is supported in later versions only.
As of 2019-10-01, optional chaining is available in TypeScript 3.7 beta.
I don't know if the current version of WebStorm can be configured to use the beta, but the early release version (2019.3 EAP #5) supports TypeScript 3.7.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With