- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.1k
Closed as not planned
Labels
Not a DefectThis behavior is one of several equally-correct optionsThis behavior is one of several equally-correct options
Description
Bug Report
π Search Terms
π Version & Regression Information
- This is wrong behaivor of extendsoperator
- This changed between versions 3.3.3 and 3.5.1
- Most likely this is the reason: Relate source types covered by a target discriminated unionΒ #30779
β― Playground Link
π» Code
type A = {x:string} | {x:number} | {x: symbol}
type B = {x:string} | {x:number} | {x: boolean}
                                       // ^ literal type here
type C = {x:string} | {x:number}
type X = {x:string | number}
// `X extends B` but not A or C
type X_A = X extends A ? "X extends A" : "X not extends A";
//   ^? X not extends A
type X_B = X extends B ? "X extends B" : "X not extends B";
//   ^? X extends B
type X_C = X extends C ? "X extends C" : "X not extends C";
//   ^? X not extends Cthe bug is reproduced with any literal type instead of boolean
π Actual behavior
X not extends A
X extends B;
X not extends C
π Expected behavior
X not extends A
X not extends B
X not extends C
Josh-Cena
Metadata
Metadata
Assignees
Labels
Not a DefectThis behavior is one of several equally-correct optionsThis behavior is one of several equally-correct options