BugDomain: check: Control FlowHelp Wanted
Repository metrics
- Stars
- Â (48,455 stars)
- PR merge metrics
-  (å¹³åããŒãž 6d 17h) (30d ã§ 9 merged PRs)
説æ
ð 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