- Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed
Description
Bug Report
🔎 Search Terms
type guard conditional type
🕗 Version & Regression Information
- This changed between versions 4.2.3 and 4.3.2
⏯ Playground Link
Playground link with relevant code
💻 Code
interfaceA<S>{a: S}interfaceB<S>{b: S}interfaceC<S>{c: S}typeU1<S>=A<S>|B<S>|C<S>functionf1<S>(u: U1<S>): u is B<S>|C<S>{returnfalse}functiontest1<S>(x: U1<S>){if(!f1(x)){x.a//OK}}typeCond<S>=Sextendsnumber ? B<S> : C<S>typeU2<S>=A<S>|Cond<S>functionf2<S>(u: U2<S>): u is Cond<S>{returnfalse}functiontest2<S>(x: U2<S>){if(!f2(x)){x.a//ERROR}}🙁 Actual behavior
The type guard is unable to narrow the type of x to A
🙂 Expected behavior
The type guard should narrow the type of x to A because it is not assignable to Cond<S>
bbenezech, KnorpelSenf and twavv
Metadata
Metadata
Assignees
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed