diff --git a/tests/baselines/reference/mappedTypeInferenceAliasSubstitution.symbols b/tests/baselines/reference/mappedTypeInferenceAliasSubstitution.symbols new file mode 100644 index 0000000000000..8ee251c372097 --- /dev/null +++ b/tests/baselines/reference/mappedTypeInferenceAliasSubstitution.symbols @@ -0,0 +1,52 @@ +=== tests/cases/compiler/mappedTypeInferenceAliasSubstitution.ts === +// repro from #31616 + +const v = { test: { smth: 5 } }; +>v : Symbol(v, Decl(mappedTypeInferenceAliasSubstitution.ts, 2, 5)) +>test : Symbol(test, Decl(mappedTypeInferenceAliasSubstitution.ts, 2, 11)) +>smth : Symbol(smth, Decl(mappedTypeInferenceAliasSubstitution.ts, 2, 19)) + +type Field = { [K in A]: R } +>Field : Symbol(Field, Decl(mappedTypeInferenceAliasSubstitution.ts, 2, 32)) +>A : Symbol(A, Decl(mappedTypeInferenceAliasSubstitution.ts, 4, 11)) +>R : Symbol(R, Decl(mappedTypeInferenceAliasSubstitution.ts, 4, 28)) +>K : Symbol(K, Decl(mappedTypeInferenceAliasSubstitution.ts, 4, 37)) +>A : Symbol(A, Decl(mappedTypeInferenceAliasSubstitution.ts, 4, 11)) +>R : Symbol(R, Decl(mappedTypeInferenceAliasSubstitution.ts, 4, 28)) + +const f = (x: { [K in A]: Field }): R => ({} as any); +>f : Symbol(f, Decl(mappedTypeInferenceAliasSubstitution.ts, 6, 5)) +>A : Symbol(A, Decl(mappedTypeInferenceAliasSubstitution.ts, 6, 11)) +>B : Symbol(B, Decl(mappedTypeInferenceAliasSubstitution.ts, 6, 28)) +>R : Symbol(R, Decl(mappedTypeInferenceAliasSubstitution.ts, 6, 46)) +>x : Symbol(x, Decl(mappedTypeInferenceAliasSubstitution.ts, 6, 50)) +>K : Symbol(K, Decl(mappedTypeInferenceAliasSubstitution.ts, 6, 56)) +>A : Symbol(A, Decl(mappedTypeInferenceAliasSubstitution.ts, 6, 11)) +>Field : Symbol(Field, Decl(mappedTypeInferenceAliasSubstitution.ts, 2, 32)) +>B : Symbol(B, Decl(mappedTypeInferenceAliasSubstitution.ts, 6, 28)) +>R : Symbol(R, Decl(mappedTypeInferenceAliasSubstitution.ts, 6, 46)) +>R : Symbol(R, Decl(mappedTypeInferenceAliasSubstitution.ts, 6, 46)) + +const r1 = f(v); +>r1 : Symbol(r1, Decl(mappedTypeInferenceAliasSubstitution.ts, 7, 5)) +>f : Symbol(f, Decl(mappedTypeInferenceAliasSubstitution.ts, 6, 5)) +>v : Symbol(v, Decl(mappedTypeInferenceAliasSubstitution.ts, 2, 5)) + +const g = (x: Field>): R => ({} as any); +>g : Symbol(g, Decl(mappedTypeInferenceAliasSubstitution.ts, 9, 5)) +>A : Symbol(A, Decl(mappedTypeInferenceAliasSubstitution.ts, 9, 11)) +>B : Symbol(B, Decl(mappedTypeInferenceAliasSubstitution.ts, 9, 28)) +>R : Symbol(R, Decl(mappedTypeInferenceAliasSubstitution.ts, 9, 46)) +>x : Symbol(x, Decl(mappedTypeInferenceAliasSubstitution.ts, 9, 50)) +>Field : Symbol(Field, Decl(mappedTypeInferenceAliasSubstitution.ts, 2, 32)) +>A : Symbol(A, Decl(mappedTypeInferenceAliasSubstitution.ts, 9, 11)) +>Field : Symbol(Field, Decl(mappedTypeInferenceAliasSubstitution.ts, 2, 32)) +>B : Symbol(B, Decl(mappedTypeInferenceAliasSubstitution.ts, 9, 28)) +>R : Symbol(R, Decl(mappedTypeInferenceAliasSubstitution.ts, 9, 46)) +>R : Symbol(R, Decl(mappedTypeInferenceAliasSubstitution.ts, 9, 46)) + +const r2 = g(v); +>r2 : Symbol(r2, Decl(mappedTypeInferenceAliasSubstitution.ts, 10, 5)) +>g : Symbol(g, Decl(mappedTypeInferenceAliasSubstitution.ts, 9, 5)) +>v : Symbol(v, Decl(mappedTypeInferenceAliasSubstitution.ts, 2, 5)) + diff --git a/tests/baselines/reference/mappedTypeInferenceAliasSubstitution.types b/tests/baselines/reference/mappedTypeInferenceAliasSubstitution.types new file mode 100644 index 0000000000000..8c84412414f61 --- /dev/null +++ b/tests/baselines/reference/mappedTypeInferenceAliasSubstitution.types @@ -0,0 +1,42 @@ +=== tests/cases/compiler/mappedTypeInferenceAliasSubstitution.ts === +// repro from #31616 + +const v = { test: { smth: 5 } }; +>v : { test: { smth: number; }; } +>{ test: { smth: 5 } } : { test: { smth: number; }; } +>test : { smth: number; } +>{ smth: 5 } : { smth: number; } +>smth : number +>5 : 5 + +type Field = { [K in A]: R } +>Field : Field + +const f = (x: { [K in A]: Field }): R => ({} as any); +>f : (x: { [K in A]: Field; }) => R +>(x: { [K in A]: Field }): R => ({} as any) : (x: { [K in A]: Field; }) => R +>x : { [K in A]: Field; } +>({} as any) : any +>{} as any : any +>{} : {} + +const r1 = f(v); +>r1 : number +>f(v) : number +>f : (x: { [K in A]: Field; }) => R +>v : { test: { smth: number; }; } + +const g = (x: Field>): R => ({} as any); +>g : (x: Field>) => R +>(x: Field>): R => ({} as any) : (x: Field>) => R +>x : Field> +>({} as any) : any +>{} as any : any +>{} : {} + +const r2 = g(v); +>r2 : number +>g(v) : number +>g : (x: Field>) => R +>v : { test: { smth: number; }; } + diff --git a/tests/cases/compiler/mappedTypeInferenceAliasSubstitution.ts b/tests/cases/compiler/mappedTypeInferenceAliasSubstitution.ts new file mode 100644 index 0000000000000..a72cc4c3ed280 --- /dev/null +++ b/tests/cases/compiler/mappedTypeInferenceAliasSubstitution.ts @@ -0,0 +1,14 @@ +// @strict: true +// @noEmit: true + +// repro from #31616 + +const v = { test: { smth: 5 } }; + +type Field = { [K in A]: R } + +const f = (x: { [K in A]: Field }): R => ({} as any); +const r1 = f(v); + +const g = (x: Field>): R => ({} as any); +const r2 = g(v);