diff --git a/tests/cases/conformance/types/conditional/conditionalTypes1.ts b/tests/cases/conformance/types/conditional/conditionalTypes1.ts index 7ac6255b7d5..93069138b36 100644 --- a/tests/cases/conformance/types/conditional/conditionalTypes1.ts +++ b/tests/cases/conformance/types/conditional/conditionalTypes1.ts @@ -226,3 +226,33 @@ type T80 = Eq2; // true type T81 = Eq2; // false type T82 = Eq2; // false type T83 = Eq2; // true + +// Repro from #21756 + +type Foo = T extends string ? boolean : number; +type Bar = T extends string ? boolean : number; +const convert = (value: Foo): Bar => value; + +type Baz = Foo; +const convert2 = (value: Foo): Baz => value; + +function f31() { + type T1 = T extends string ? boolean : number; + type T2 = T extends string ? boolean : number; + var x: T1; + var x: T2; +} + +function f32() { + type T1 = T & U extends string ? boolean : number; + type T2 = Foo; + var z: T1; + var z: T2; // Error, T2 is distributive, T1 isn't +} + +function f33() { + type T1 = Foo; + type T2 = Bar; + var z: T1; + var z: T2; +}