diff --git a/tests/baselines/reference/inferTypes1.errors.txt b/tests/baselines/reference/inferTypes1.errors.txt index d5b91a426e3..80edc31d37c 100644 --- a/tests/baselines/reference/inferTypes1.errors.txt +++ b/tests/baselines/reference/inferTypes1.errors.txt @@ -12,9 +12,10 @@ tests/cases/conformance/types/conditional/inferTypes1.ts(72,43): error TS2304: C tests/cases/conformance/types/conditional/inferTypes1.ts(72,43): error TS4081: Exported type alias 'T62' has or is using private name 'U'. tests/cases/conformance/types/conditional/inferTypes1.ts(78,44): error TS2344: Type 'U' does not satisfy the constraint 'string'. Type 'number' is not assignable to type 'string'. +tests/cases/conformance/types/conditional/inferTypes1.ts(131,40): error TS2322: Type 'T' is not assignable to type 'string'. -==== tests/cases/conformance/types/conditional/inferTypes1.ts (12 errors) ==== +==== tests/cases/conformance/types/conditional/inferTypes1.ts (13 errors) ==== type Unpacked = T extends (infer U)[] ? U : T extends (...args: any[]) => infer U ? U : @@ -167,4 +168,11 @@ tests/cases/conformance/types/conditional/inferTypes1.ts(78,44): error TS2344: T type A2 = [T, U]; type B2 = S extends A2 ? [T, U] : never; type C2 = S extends A2 ? [T, U] : never; + + // Repro from #21735 + + type A = T extends string ? { [P in T]: void; } : T; + type B = string extends T ? { [P in T]: void; } : T; // Error + ~ +!!! error TS2322: Type 'T' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/inferTypes1.js b/tests/baselines/reference/inferTypes1.js index 56bc71e5a71..21cada9c71b 100644 --- a/tests/baselines/reference/inferTypes1.js +++ b/tests/baselines/reference/inferTypes1.js @@ -125,6 +125,11 @@ type B1 = S extends A1 ? [T, U] : never; type A2 = [T, U]; type B2 = S extends A2 ? [T, U] : never; type C2 = S extends A2 ? [T, U] : never; + +// Repro from #21735 + +type A = T extends string ? { [P in T]: void; } : T; +type B = string extends T ? { [P in T]: void; } : T; // Error //// [inferTypes1.js] diff --git a/tests/baselines/reference/inferTypes1.symbols b/tests/baselines/reference/inferTypes1.symbols index 1e5468e2b8e..6e8a9670f29 100644 --- a/tests/baselines/reference/inferTypes1.symbols +++ b/tests/baselines/reference/inferTypes1.symbols @@ -551,3 +551,21 @@ type C2 = S extends A2 ? [T, U] : never; >T : Symbol(T, Decl(inferTypes1.ts, 125, 47)) >U : Symbol(U, Decl(inferTypes1.ts, 125, 10)) +// Repro from #21735 + +type A = T extends string ? { [P in T]: void; } : T; +>A : Symbol(A, Decl(inferTypes1.ts, 125, 71)) +>T : Symbol(T, Decl(inferTypes1.ts, 129, 7)) +>T : Symbol(T, Decl(inferTypes1.ts, 129, 7)) +>P : Symbol(P, Decl(inferTypes1.ts, 129, 34)) +>T : Symbol(T, Decl(inferTypes1.ts, 129, 7)) +>T : Symbol(T, Decl(inferTypes1.ts, 129, 7)) + +type B = string extends T ? { [P in T]: void; } : T; // Error +>B : Symbol(B, Decl(inferTypes1.ts, 129, 55)) +>T : Symbol(T, Decl(inferTypes1.ts, 130, 7)) +>T : Symbol(T, Decl(inferTypes1.ts, 130, 7)) +>P : Symbol(P, Decl(inferTypes1.ts, 130, 34)) +>T : Symbol(T, Decl(inferTypes1.ts, 130, 7)) +>T : Symbol(T, Decl(inferTypes1.ts, 130, 7)) + diff --git a/tests/baselines/reference/inferTypes1.types b/tests/baselines/reference/inferTypes1.types index ca60ea57d0e..141a3d0aac6 100644 --- a/tests/baselines/reference/inferTypes1.types +++ b/tests/baselines/reference/inferTypes1.types @@ -558,3 +558,21 @@ type C2 = S extends A2 ? [T, U] : never; >T : T >U : U +// Repro from #21735 + +type A = T extends string ? { [P in T]: void; } : T; +>A : A +>T : T +>T : T +>P : P +>T : T +>T : T + +type B = string extends T ? { [P in T]: void; } : T; // Error +>B : B +>T : T +>T : T +>P : P +>T : T +>T : T +