Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TS1109, WebStorm incorrectly reacting on optional chaining

Ts1109 error

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?

like image 742
Winni Avatar asked Feb 27 '19 09:02

Winni


3 Answers

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

like image 94
lena Avatar answered Nov 15 '22 14:11

lena


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.

enter image description here

like image 33
Archit Garg Avatar answered Nov 15 '22 15:11

Archit Garg


As of 2019-10-01, optional chaining is available in TypeScript 3.7 beta.

  • https://devblogs.microsoft.com/typescript/announcing-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.

  • https://blog.jetbrains.com/webstorm/2019/10/webstorm-2019-3-eap-5/
like image 40
egrubbs Avatar answered Nov 15 '22 14:11

egrubbs