diff --git a/tests/baselines/reference/inferenceAndSelfReferentialConstraint.js b/tests/baselines/reference/inferenceAndSelfReferentialConstraint.js new file mode 100644 index 00000000000..a13f100c2da --- /dev/null +++ b/tests/baselines/reference/inferenceAndSelfReferentialConstraint.js @@ -0,0 +1,52 @@ +//// [inferenceAndSelfReferentialConstraint.ts] +// @strict + +// Repro from #29520 + +type Test = { + [P in K | "foo"]: P extends "foo" ? true : () => any +} + +function test>(arg: T) { + return arg; +} + +const res1 = test({ + foo: true, + bar() { + } +}); + +const res2 = test({ + foo: true, + bar: function () { + } +}); + +const res3 = test({ + foo: true, + bar: () => { + } +}); + + +//// [inferenceAndSelfReferentialConstraint.js] +// @strict +function test(arg) { + return arg; +} +var res1 = test({ + foo: true, + bar: function () { + } +}); +var res2 = test({ + foo: true, + bar: function () { + } +}); +var res3 = test({ + foo: true, + bar: function () { + } +}); diff --git a/tests/baselines/reference/inferenceAndSelfReferentialConstraint.symbols b/tests/baselines/reference/inferenceAndSelfReferentialConstraint.symbols new file mode 100644 index 00000000000..121736623ea --- /dev/null +++ b/tests/baselines/reference/inferenceAndSelfReferentialConstraint.symbols @@ -0,0 +1,63 @@ +=== tests/cases/compiler/inferenceAndSelfReferentialConstraint.ts === +// @strict + +// Repro from #29520 + +type Test = { +>Test : Symbol(Test, Decl(inferenceAndSelfReferentialConstraint.ts, 0, 0)) +>K : Symbol(K, Decl(inferenceAndSelfReferentialConstraint.ts, 4, 10)) + + [P in K | "foo"]: P extends "foo" ? true : () => any +>P : Symbol(P, Decl(inferenceAndSelfReferentialConstraint.ts, 5, 3)) +>K : Symbol(K, Decl(inferenceAndSelfReferentialConstraint.ts, 4, 10)) +>P : Symbol(P, Decl(inferenceAndSelfReferentialConstraint.ts, 5, 3)) +} + +function test>(arg: T) { +>test : Symbol(test, Decl(inferenceAndSelfReferentialConstraint.ts, 6, 1)) +>T : Symbol(T, Decl(inferenceAndSelfReferentialConstraint.ts, 8, 14)) +>Test : Symbol(Test, Decl(inferenceAndSelfReferentialConstraint.ts, 0, 0)) +>T : Symbol(T, Decl(inferenceAndSelfReferentialConstraint.ts, 8, 14)) +>arg : Symbol(arg, Decl(inferenceAndSelfReferentialConstraint.ts, 8, 39)) +>T : Symbol(T, Decl(inferenceAndSelfReferentialConstraint.ts, 8, 14)) + + return arg; +>arg : Symbol(arg, Decl(inferenceAndSelfReferentialConstraint.ts, 8, 39)) +} + +const res1 = test({ +>res1 : Symbol(res1, Decl(inferenceAndSelfReferentialConstraint.ts, 12, 5)) +>test : Symbol(test, Decl(inferenceAndSelfReferentialConstraint.ts, 6, 1)) + + foo: true, +>foo : Symbol(foo, Decl(inferenceAndSelfReferentialConstraint.ts, 12, 19)) + + bar() { +>bar : Symbol(bar, Decl(inferenceAndSelfReferentialConstraint.ts, 13, 12)) + } +}); + +const res2 = test({ +>res2 : Symbol(res2, Decl(inferenceAndSelfReferentialConstraint.ts, 18, 5)) +>test : Symbol(test, Decl(inferenceAndSelfReferentialConstraint.ts, 6, 1)) + + foo: true, +>foo : Symbol(foo, Decl(inferenceAndSelfReferentialConstraint.ts, 18, 19)) + + bar: function () { +>bar : Symbol(bar, Decl(inferenceAndSelfReferentialConstraint.ts, 19, 12)) + } +}); + +const res3 = test({ +>res3 : Symbol(res3, Decl(inferenceAndSelfReferentialConstraint.ts, 24, 5)) +>test : Symbol(test, Decl(inferenceAndSelfReferentialConstraint.ts, 6, 1)) + + foo: true, +>foo : Symbol(foo, Decl(inferenceAndSelfReferentialConstraint.ts, 24, 19)) + + bar: () => { +>bar : Symbol(bar, Decl(inferenceAndSelfReferentialConstraint.ts, 25, 12)) + } +}); + diff --git a/tests/baselines/reference/inferenceAndSelfReferentialConstraint.types b/tests/baselines/reference/inferenceAndSelfReferentialConstraint.types new file mode 100644 index 00000000000..c4c723baaa0 --- /dev/null +++ b/tests/baselines/reference/inferenceAndSelfReferentialConstraint.types @@ -0,0 +1,67 @@ +=== tests/cases/compiler/inferenceAndSelfReferentialConstraint.ts === +// @strict + +// Repro from #29520 + +type Test = { +>Test : Test + + [P in K | "foo"]: P extends "foo" ? true : () => any +>true : true +} + +function test>(arg: T) { +>test : >(arg: T) => T +>arg : T + + return arg; +>arg : T +} + +const res1 = test({ +>res1 : { foo: true; bar(): void; } +>test({ foo: true, bar() { }}) : { foo: true; bar(): void; } +>test : >(arg: T) => T +>{ foo: true, bar() { }} : { foo: true; bar(): void; } + + foo: true, +>foo : true +>true : true + + bar() { +>bar : () => void + } +}); + +const res2 = test({ +>res2 : { foo: true; bar: () => void; } +>test({ foo: true, bar: function () { }}) : { foo: true; bar: () => void; } +>test : >(arg: T) => T +>{ foo: true, bar: function () { }} : { foo: true; bar: () => void; } + + foo: true, +>foo : true +>true : true + + bar: function () { +>bar : () => void +>function () { } : () => void + } +}); + +const res3 = test({ +>res3 : { foo: true; bar: () => void; } +>test({ foo: true, bar: () => { }}) : { foo: true; bar: () => void; } +>test : >(arg: T) => T +>{ foo: true, bar: () => { }} : { foo: true; bar: () => void; } + + foo: true, +>foo : true +>true : true + + bar: () => { +>bar : () => void +>() => { } : () => void + } +}); +