false positive error after null checking with typed boolean variable instead non typed variable #56369
Labels
Working as Intended
The behavior described is the intended behavior; this is not a bug
🔎 Search Terms
false positive error after null checking with typed boolean variable instead non typed variable
strictNullChecks false positive error
🕗 Version & Regression Information
⏯ Playground Link
TypeScript: TS Playground
💻 Code
Example code
Common base
The function simply returns a type or a null:
tsconfig.json
index.ts
Code with the Issue
The following code doesn't compile. It can't recognize the null checking of the variable
index.ts
Equivalent working code
The following code is equivalent to the previous one and correctly compiles.
index.ts
🙁 Actual behavior
TypeScript can't recognize null checking of variables when the value is assigned to a typed variable and later used to do the null checking
🙂 Expected behavior
TypeScript should recognize the null checking and compile the code normally (Like it's equivalent snippet)
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: