-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Open
Labels
Possible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases
Milestone
Description
Bug Report
π Search Terms
Type Guard
π Version & Regression Information
- This changed between versions 4.9.5 and 5.0.4
β― Playground Link
π» Code
declare class Foo<Stuff extends boolean> {
stuff: Stuff extends true ? string : string | undefined;
isReady(): this is Foo<true>
}
declare const x: Foo<boolean>;
if(x.isReady()) {
x
//^? - const x: Foo<boolean>
// Should be Foo<true>
}
π Actual behavior
The Type Guard didn't change the type, which is unintuitive behavior.
π Expected behavior
The method should act as a type guard and change the type
Metadata
Metadata
Assignees
Labels
Possible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases