@@ -17,7 +17,7 @@ tests/cases/conformance/types/conditional/inferTypes1.ts(75,43): error TS2304: C
17
17
tests/cases/conformance/types/conditional/inferTypes1.ts(75,43): error TS4081: Exported type alias 'T62' has or is using private name 'U'.
18
18
tests/cases/conformance/types/conditional/inferTypes1.ts(81,44): error TS2344: Type 'U' does not satisfy the constraint 'string'.
19
19
Type 'number' is not assignable to type 'string'.
20
- tests/cases/conformance/types/conditional/inferTypes1.ts(134 ,40): error TS2322: Type 'T' is not assignable to type 'string'.
20
+ tests/cases/conformance/types/conditional/inferTypes1.ts(143 ,40): error TS2322: Type 'T' is not assignable to type 'string'.
21
21
22
22
23
23
==== tests/cases/conformance/types/conditional/inferTypes1.ts (16 errors) ====
@@ -144,6 +144,15 @@ tests/cases/conformance/types/conditional/inferTypes1.ts(134,40): error TS2322:
144
144
type T77<T> = T extends T76<infer X, infer Y> ? T76<X, Y> : never;
145
145
type T78<T> = T extends T76<infer X, infer X> ? T76<X, X> : never;
146
146
147
+ type Foo<T extends string, U extends T> = [T, U];
148
+ type Bar<T> = T extends Foo<infer X, infer Y> ? Foo<X, Y> : never;
149
+
150
+ type T90 = Bar<[string, string]>; // [string, string]
151
+ type T91 = Bar<[string, "a"]>; // [string, "a"]
152
+ type T92 = Bar<[string, "a"] & { x: string }>; // [string, "a"]
153
+ type T93 = Bar<["a", string]>; // never
154
+ type T94 = Bar<[number, number]>; // never
155
+
147
156
// Example from #21496
148
157
149
158
type JsonifiedObject<T extends object> = { [K in keyof T]: Jsonified<T[K]> };
@@ -206,4 +215,12 @@ tests/cases/conformance/types/conditional/inferTypes1.ts(134,40): error TS2322:
206
215
207
216
type T80 = MatchingKeys<test, void>;
208
217
type T81 = VoidKeys<test>;
218
+
219
+ // Repro from #22221
220
+
221
+ type MustBeString<T extends string> = T;
222
+ type EnsureIsString<T> = T extends MustBeString<infer U> ? U : never;
223
+
224
+ type Test1 = EnsureIsString<"hello">; // "hello"
225
+ type Test2 = EnsureIsString<42>; // never
209
226
0 commit comments