2

I installed WebStorm 2020.1 yesterday.

Suddenly I got a bunch of TS2532 errors.

enter image description here

How can this be "possible undefined"? The selectedOwner && protects against that?

I tried to disabled this stupid error with "strictNullChecks": false, but has no effect.

LazyOne
  • 158,824
  • 45
  • 388
  • 391
Joe
  • 4,274
  • 32
  • 95
  • 175

2 Answers2

1

Webstorm is occasionally slow to propagate the changes.

What I would recommend is to check and ensure that you the webstorm TypeSript service is using the right TypeScript version, and that it is using the right tsconfig.json file on your project.

On the Webstorm menu, go to Preferences -> Languages & Frameworks -> TypeScript.

Ensure that is is loading TypeScript from your project's node_modules, and not anywhere else. In addition, the compile scope should be set to Project Files

It may also help if you restart TypeScript service.

In addition, if you are using TypeScript 3.7.5 and above, you can simplify your conditional rendering by using optional chaining:

selectedLocalOwner?.id && .....
wentjun
  • 40,384
  • 10
  • 95
  • 107
1

You say

I tried to disabled this stupid error with "strictNullChecks": false, but has no effect.

Where did you put this check? I have put it in my tsconfig.json as described here: https://stackoverflow.com/a/48401853/2528609 and it works just fine.

mvermand
  • 5,829
  • 7
  • 48
  • 74