Closed
Description
Bug Report
See code snippet below, if a type is a union with undefined it shouldn't throw the TS2801 error "This condition will always return true since this 'Promise' appears to always be defined."
Especially not when strictNullChecks: true
🔎 Search Terms
- TS2801
- Did you forget to use 'await'
- This condition will always return true since this * appears to always be defined.
🕗 Version & Regression Information
v4.3.0-beta
- This changed between versions 4.2.x and 4.3.x
⏯ Playground Link
Playground link, strictNullChecks
is on
💻 Code
const x: Promise<number> = Promise.resolve(1);
const y: Promise<number> | undefined = x;
if (y) { // 🔴 this line should not error since y could be undefined so it's a valid check
// ...
}
🙁 Actual behaviour
"This condition will always return true since this 'Promise' appears to always be defined."
🙂 Expected behaviour
no error
Metadata
Metadata
Assignees
Labels
No labels