BugDomain: check: Control FlowHelp Wanted
Metriche repository
- Star
- (48.455 star)
- Metriche merge PR
- (Merge medio 6g 17h) (9 PR mergiate in 30 g)
Descrizione
🔎 Search Terms
narrowing undefined, incorrect type narrowing, incorrect if statement narrowing
🕗 Version & Regression Information
- This changed between versions 5.2 and 5.3
⏯ Playground Link
💻 Code
declare class A {
IsA(): this is A;
}
declare const pattern: A | undefined;
function applyPattern() {
if (pattern?.IsA() === false) {
pattern;
// ^?
return;
}
pattern;
// ^?
}
🙁 Actual behavior
pattern is narrowed down to A, removing the undefined
🙂 Expected behavior
pattern should only be narrowed to A | undefined
Additional information about the issue
No response