diff --git a/tests/cases/conformance/types/conditional/conditionalTypes1.ts b/tests/cases/conformance/types/conditional/conditionalTypes1.ts index 94a802a0ffc..9449cc6d766 100644 --- a/tests/cases/conformance/types/conditional/conditionalTypes1.ts +++ b/tests/cases/conformance/types/conditional/conditionalTypes1.ts @@ -287,3 +287,33 @@ function f50() { type A = Omit<{ a: void; b: never; }>; // 'a' type B = Omit2<{ a: void; b: never; }>; // 'a' } + +// Repro from #21862 + +type OldDiff = ( + & { [P in T]: P; } + & { [P in U]: never; } + & { [x: string]: never; } +)[T]; +type NewDiff = T extends U ? never : T; +interface A { + a: 'a'; +} +interface B1 extends A { + b: 'b'; + c: OldDiff; +} +interface B2 extends A { + b: 'b'; + c: NewDiff; +} +type c1 = B1['c']; // 'c' | 'b' +type c2 = B2['c']; // 'c' | 'b' + +// Repro from #21929 + +type NonFooKeys1 = OldDiff; +type NonFooKeys2 = Exclude; + +type Test1 = NonFooKeys1<{foo: 1, bar: 2, baz: 3}>; // "bar" | "baz" +type Test2 = NonFooKeys2<{foo: 1, bar: 2, baz: 3}>; // "bar" | "baz"