diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 80b61edd3657a..f5811f4bce68a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -31877,14 +31877,21 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // When the length is known and the index is after all spread elements we compute the offset from the element // to the end and the number of ending fixed elements in the contextual tuple type. const offset = length !== undefined && (lastSpreadIndex === undefined || index > lastSpreadIndex) ? length - index : 0; - const fixedEndLength = offset > 0 && (t.target.combinedFlags & ElementFlags.Variable) ? getEndElementCount(t.target, ElementFlags.Fixed) : 0; + const fixedEndLength = getEndElementCount(t.target, ElementFlags.Fixed); + const endSkipCount = offset > 0 && (t.target.combinedFlags & ElementFlags.Variable) ? fixedEndLength : 0; + const arity = getTypeReferenceArity(t); // If the offset is within the ending fixed part of the contextual tuple type, return the type of the contextual // tuple element. - if (offset > 0 && offset <= fixedEndLength) { - return getTypeArguments(t)[getTypeReferenceArity(t) - offset]; + if (offset > 0 && offset <= endSkipCount) { + return getTypeArguments(t)[arity - offset]; + } + const middleLength = arity - t.target.fixedLength - fixedEndLength; + const singleVariadicIndex = middleLength === 1 && t.target.elementFlags[t.target.fixedLength] & ElementFlags.Variadic ? t.target.fixedLength : -1; + if (singleVariadicIndex !== -1 && (firstSpreadIndex === undefined || index < firstSpreadIndex)) { + return getIndexedAccessType(getTypeArguments(t)[singleVariadicIndex], getStringLiteralType("" + (index - singleVariadicIndex))); } // Return a union of the possible contextual element types with no subtype reduction. - return getElementTypeOfSliceOfTupleType(t, firstSpreadIndex === undefined ? t.target.fixedLength : Math.min(t.target.fixedLength, firstSpreadIndex), length === undefined || lastSpreadIndex === undefined ? fixedEndLength : Math.min(fixedEndLength, length - lastSpreadIndex), /*writing*/ false, /*noReductions*/ true); + return getElementTypeOfSliceOfTupleType(t, firstSpreadIndex === undefined ? t.target.fixedLength : Math.min(t.target.fixedLength, firstSpreadIndex), length === undefined || lastSpreadIndex === undefined ? endSkipCount : Math.min(endSkipCount, length - lastSpreadIndex), /*writing*/ false, /*noReductions*/ true); } // If element index is known and a contextual property with that name exists, return it. Otherwise return the // iterated or element type of the contextual type. diff --git a/tests/baselines/reference/reverseMappedTuples1.errors.txt b/tests/baselines/reference/reverseMappedTuples1.errors.txt new file mode 100644 index 0000000000000..eebab112819ea --- /dev/null +++ b/tests/baselines/reference/reverseMappedTuples1.errors.txt @@ -0,0 +1,215 @@ +reverseMappedTuples1.ts(39,15): error TS7006: Parameter 't' implicitly has an 'any' type. +reverseMappedTuples1.ts(44,15): error TS7006: Parameter 't' implicitly has an 'any' type. +reverseMappedTuples1.ts(63,15): error TS7006: Parameter 't' implicitly has an 'any' type. +reverseMappedTuples1.ts(68,15): error TS7006: Parameter 't' implicitly has an 'any' type. +reverseMappedTuples1.ts(69,15): error TS7006: Parameter 't' implicitly has an 'any' type. +reverseMappedTuples1.ts(97,15): error TS7006: Parameter 't' implicitly has an 'any' type. +reverseMappedTuples1.ts(112,4): error TS2322: Type 'typeof Bar' is not assignable to type 'Constructor'. + Property 'test' is missing in type 'Bar' but required in type 'Foo'. +reverseMappedTuples1.ts(126,4): error TS2322: Type 'typeof Baz' is not assignable to type 'Constructor'. + Property 'test' is missing in type 'Baz' but required in type 'Foo'. +reverseMappedTuples1.ts(145,15): error TS7006: Parameter 't' implicitly has an 'any' type. +reverseMappedTuples1.ts(146,15): error TS7006: Parameter 't' implicitly has an 'any' type. +reverseMappedTuples1.ts(147,15): error TS7006: Parameter 't' implicitly has an 'any' type. +reverseMappedTuples1.ts(156,15): error TS7006: Parameter 't' implicitly has an 'any' type. +reverseMappedTuples1.ts(157,15): error TS7006: Parameter 't' implicitly has an 'any' type. +reverseMappedTuples1.ts(158,15): error TS7006: Parameter 't' implicitly has an 'any' type. +reverseMappedTuples1.ts(159,15): error TS7006: Parameter 't' implicitly has an 'any' type. + + +==== reverseMappedTuples1.ts (15 errors) ==== + // https://github.com/microsoft/TypeScript/issues/58726 + + type Constructor = { + new (...args: never[]): T; + }; + + interface GenericParams { + bar: (t: T) => void; + } + + type Pair = [Constructor, GenericParams]; + + type List = { + [K in keyof T]: Pair; + }; + + class Foo { + test() {} + } + class Bar { + other() {} + } + class Baz { + third() {} + } + + declare const withFooPair: [Pair]; + declare const with2FooPairs: [Pair, Pair]; + + declare function fn1(params: List<[...T]>): T; + + const res1 = fn1([ + [Foo, { bar(t) {} }], + [Bar, { bar(t) {} }], + ]); + + const res2 = fn1([ + ...withFooPair, + [Bar, { bar(t) {} }], // implicit any + ~ +!!! error TS7006: Parameter 't' implicitly has an 'any' type. + ]); + + const res3 = fn1([ + ...with2FooPairs, + [Bar, { bar(t) {} }], // implicit any + ~ +!!! error TS7006: Parameter 't' implicitly has an 'any' type. + ]); + + const res4 = fn1([ + [Bar, { bar(t) {} }], + ...with2FooPairs, + ]); + + declare function fn2(params: List<[Foo, Foo, ...T]>): T; + + const res5 = fn2([ + [Foo, { bar(t) {} }], + [Foo, { bar(t) {} }], + [Bar, { bar(t) {} }], + [Baz, { bar(t) {} }], + ]); + + const res6 = fn2([ + ...with2FooPairs, + [Bar, { bar(t) {} }], // implicit any + ~ +!!! error TS7006: Parameter 't' implicitly has an 'any' type. + ]); + + const res7 = fn2([ + ...with2FooPairs, + [Bar, { bar(t) {} }], // implicit any + ~ +!!! error TS7006: Parameter 't' implicitly has an 'any' type. + [Baz, { bar(t) {} }], // implicit any + ~ +!!! error TS7006: Parameter 't' implicitly has an 'any' type. + ]); + + declare function fn3(params: List<[...T, Foo, Foo]>): T; + + const res8 = fn3([ + [Bar, { bar(t) {} }], + [Baz, { bar(t) {} }], + [Foo, { bar(t) {} }], + [Foo, { bar(t) {} }], + ]); + + const res9 = fn3([ + [Bar, { bar(t) {} }], + [Baz, { bar(t) {} }], + ...with2FooPairs + ]); + + const res10 = fn3([ + [Bar, { bar(t) {} }], + [Baz, { bar(t) {} }], + ...withFooPair, + [Foo, { bar(t) {} }], + ]); + + const res11 = fn3([ + [Bar, { bar(t) {} }], + [Baz, { bar(t) {} }], + [Foo, { bar(t) {} }], + ~ +!!! error TS7006: Parameter 't' implicitly has an 'any' type. + ...withFooPair, + ]); + + declare function fn4(params: List<[Foo, Foo?, ...T]>): T; + + const res12 = fn4([ + [Foo, { bar(t) {} }], + [Foo, { bar(t) {} }], + [Bar, { bar(t) {} }], + [Baz, { bar(t) {} }], + ]); + + const res13 = fn4([ + [Foo, { bar(t) {} }], + [Bar, { bar(t) {} }], // error + ~~~ +!!! error TS2322: Type 'typeof Bar' is not assignable to type 'Constructor'. +!!! error TS2322: Property 'test' is missing in type 'Bar' but required in type 'Foo'. +!!! related TS2728 reverseMappedTuples1.ts:18:3: 'test' is declared here. + [Baz, { bar(t) {} }], + ]); + + declare function fn5(params: List<[...T, Foo?]>): T; + + const res14 = fn5([ + [Bar, { bar(t) {} }], + [Baz, { bar(t) {} }], + [Foo, { bar(t) {} }], + ]); + + const res15 = fn5([ + [Bar, { bar(t) {} }], + [Baz, { bar(t) {} }], // error, inferred [Bar, Baz] would satisfy but the checker prefers picking up trailing optional element for contextual typing etc + ~~~ +!!! error TS2322: Type 'typeof Baz' is not assignable to type 'Constructor'. +!!! error TS2322: Property 'test' is missing in type 'Baz' but required in type 'Foo'. +!!! related TS2728 reverseMappedTuples1.ts:18:3: 'test' is declared here. + ]); + + declare function fn6(params: List<[Foo, Foo, ...T, Foo, Foo]>): T; + + const res16 = fn6([ + [Foo, { bar(t) {} }], + [Foo, { bar(t) {} }], + [Bar, { bar(t) {} }], + [Baz, { bar(t) {} }], + [Foo, { bar(t) {} }], + [Foo, { bar(t) {} }], + ]); + + declare function fn7(params: List<[Foo, Foo, ...T, ...T2, Foo]>): [T, T2]; + + const res17 = fn7([ + [Foo, { bar(t) {} }], + [Foo, { bar(t) {} }], + [Bar, { bar(t) {} }], // implicit any + ~ +!!! error TS7006: Parameter 't' implicitly has an 'any' type. + [Baz, { bar(t) {} }], // implicit any + ~ +!!! error TS7006: Parameter 't' implicitly has an 'any' type. + [Foo, { bar(t) {} }], // implicit any + ~ +!!! error TS7006: Parameter 't' implicitly has an 'any' type. + [Foo, { bar(t) {} }], + ]); + + declare function fn8(params: List<[Foo, Foo, ...T, ...Foo[]]>): T; + + const res18 = fn8([ + [Foo, { bar(t) {} }], + [Foo, { bar(t) {} }], + [Bar, { bar(t) {} }], // implicit any + ~ +!!! error TS7006: Parameter 't' implicitly has an 'any' type. + [Baz, { bar(t) {} }], // implicit any + ~ +!!! error TS7006: Parameter 't' implicitly has an 'any' type. + [Foo, { bar(t) {} }], // implicit any + ~ +!!! error TS7006: Parameter 't' implicitly has an 'any' type. + [Foo, { bar(t) {} }], // implicit any + ~ +!!! error TS7006: Parameter 't' implicitly has an 'any' type. + ]); + \ No newline at end of file diff --git a/tests/baselines/reference/reverseMappedTuples1.symbols b/tests/baselines/reference/reverseMappedTuples1.symbols new file mode 100644 index 0000000000000..6914722a63414 --- /dev/null +++ b/tests/baselines/reference/reverseMappedTuples1.symbols @@ -0,0 +1,563 @@ +//// [tests/cases/compiler/reverseMappedTuples1.ts] //// + +=== reverseMappedTuples1.ts === +// https://github.com/microsoft/TypeScript/issues/58726 + +type Constructor = { +>Constructor : Symbol(Constructor, Decl(reverseMappedTuples1.ts, 0, 0)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 2, 17)) + + new (...args: never[]): T; +>args : Symbol(args, Decl(reverseMappedTuples1.ts, 3, 7)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 2, 17)) + +}; + +interface GenericParams { +>GenericParams : Symbol(GenericParams, Decl(reverseMappedTuples1.ts, 4, 2)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 6, 24)) + + bar: (t: T) => void; +>bar : Symbol(GenericParams.bar, Decl(reverseMappedTuples1.ts, 6, 28)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 7, 8)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 6, 24)) +} + +type Pair = [Constructor, GenericParams]; +>Pair : Symbol(Pair, Decl(reverseMappedTuples1.ts, 8, 1)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 10, 10)) +>Constructor : Symbol(Constructor, Decl(reverseMappedTuples1.ts, 0, 0)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 10, 10)) +>GenericParams : Symbol(GenericParams, Decl(reverseMappedTuples1.ts, 4, 2)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 10, 10)) + +type List = { +>List : Symbol(List, Decl(reverseMappedTuples1.ts, 10, 50)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 12, 10)) + + [K in keyof T]: Pair; +>K : Symbol(K, Decl(reverseMappedTuples1.ts, 13, 3)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 12, 10)) +>Pair : Symbol(Pair, Decl(reverseMappedTuples1.ts, 8, 1)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 12, 10)) +>K : Symbol(K, Decl(reverseMappedTuples1.ts, 13, 3)) + +}; + +class Foo { +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) + + test() {} +>test : Symbol(Foo.test, Decl(reverseMappedTuples1.ts, 16, 11)) +} +class Bar { +>Bar : Symbol(Bar, Decl(reverseMappedTuples1.ts, 18, 1)) + + other() {} +>other : Symbol(Bar.other, Decl(reverseMappedTuples1.ts, 19, 11)) +} +class Baz { +>Baz : Symbol(Baz, Decl(reverseMappedTuples1.ts, 21, 1)) + + third() {} +>third : Symbol(Baz.third, Decl(reverseMappedTuples1.ts, 22, 11)) +} + +declare const withFooPair: [Pair]; +>withFooPair : Symbol(withFooPair, Decl(reverseMappedTuples1.ts, 26, 13)) +>Pair : Symbol(Pair, Decl(reverseMappedTuples1.ts, 8, 1)) +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) + +declare const with2FooPairs: [Pair, Pair]; +>with2FooPairs : Symbol(with2FooPairs, Decl(reverseMappedTuples1.ts, 27, 13)) +>Pair : Symbol(Pair, Decl(reverseMappedTuples1.ts, 8, 1)) +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>Pair : Symbol(Pair, Decl(reverseMappedTuples1.ts, 8, 1)) +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) + +declare function fn1(params: List<[...T]>): T; +>fn1 : Symbol(fn1, Decl(reverseMappedTuples1.ts, 27, 52)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 29, 21)) +>params : Symbol(params, Decl(reverseMappedTuples1.ts, 29, 46)) +>List : Symbol(List, Decl(reverseMappedTuples1.ts, 10, 50)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 29, 21)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 29, 21)) + +const res1 = fn1([ +>res1 : Symbol(res1, Decl(reverseMappedTuples1.ts, 31, 5)) +>fn1 : Symbol(fn1, Decl(reverseMappedTuples1.ts, 27, 52)) + + [Foo, { bar(t) {} }], +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 32, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 32, 14)) + + [Bar, { bar(t) {} }], +>Bar : Symbol(Bar, Decl(reverseMappedTuples1.ts, 18, 1)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 33, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 33, 14)) + +]); + +const res2 = fn1([ +>res2 : Symbol(res2, Decl(reverseMappedTuples1.ts, 36, 5)) +>fn1 : Symbol(fn1, Decl(reverseMappedTuples1.ts, 27, 52)) + + ...withFooPair, +>withFooPair : Symbol(withFooPair, Decl(reverseMappedTuples1.ts, 26, 13)) + + [Bar, { bar(t) {} }], // implicit any +>Bar : Symbol(Bar, Decl(reverseMappedTuples1.ts, 18, 1)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 38, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 38, 14)) + +]); + +const res3 = fn1([ +>res3 : Symbol(res3, Decl(reverseMappedTuples1.ts, 41, 5)) +>fn1 : Symbol(fn1, Decl(reverseMappedTuples1.ts, 27, 52)) + + ...with2FooPairs, +>with2FooPairs : Symbol(with2FooPairs, Decl(reverseMappedTuples1.ts, 27, 13)) + + [Bar, { bar(t) {} }], // implicit any +>Bar : Symbol(Bar, Decl(reverseMappedTuples1.ts, 18, 1)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 43, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 43, 14)) + +]); + +const res4 = fn1([ +>res4 : Symbol(res4, Decl(reverseMappedTuples1.ts, 46, 5)) +>fn1 : Symbol(fn1, Decl(reverseMappedTuples1.ts, 27, 52)) + + [Bar, { bar(t) {} }], +>Bar : Symbol(Bar, Decl(reverseMappedTuples1.ts, 18, 1)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 47, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 47, 14)) + + ...with2FooPairs, +>with2FooPairs : Symbol(with2FooPairs, Decl(reverseMappedTuples1.ts, 27, 13)) + +]); + +declare function fn2(params: List<[Foo, Foo, ...T]>): T; +>fn2 : Symbol(fn2, Decl(reverseMappedTuples1.ts, 49, 3)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 51, 21)) +>params : Symbol(params, Decl(reverseMappedTuples1.ts, 51, 46)) +>List : Symbol(List, Decl(reverseMappedTuples1.ts, 10, 50)) +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 51, 21)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 51, 21)) + +const res5 = fn2([ +>res5 : Symbol(res5, Decl(reverseMappedTuples1.ts, 53, 5)) +>fn2 : Symbol(fn2, Decl(reverseMappedTuples1.ts, 49, 3)) + + [Foo, { bar(t) {} }], +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 54, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 54, 14)) + + [Foo, { bar(t) {} }], +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 55, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 55, 14)) + + [Bar, { bar(t) {} }], +>Bar : Symbol(Bar, Decl(reverseMappedTuples1.ts, 18, 1)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 56, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 56, 14)) + + [Baz, { bar(t) {} }], +>Baz : Symbol(Baz, Decl(reverseMappedTuples1.ts, 21, 1)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 57, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 57, 14)) + +]); + +const res6 = fn2([ +>res6 : Symbol(res6, Decl(reverseMappedTuples1.ts, 60, 5)) +>fn2 : Symbol(fn2, Decl(reverseMappedTuples1.ts, 49, 3)) + + ...with2FooPairs, +>with2FooPairs : Symbol(with2FooPairs, Decl(reverseMappedTuples1.ts, 27, 13)) + + [Bar, { bar(t) {} }], // implicit any +>Bar : Symbol(Bar, Decl(reverseMappedTuples1.ts, 18, 1)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 62, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 62, 14)) + +]); + +const res7 = fn2([ +>res7 : Symbol(res7, Decl(reverseMappedTuples1.ts, 65, 5)) +>fn2 : Symbol(fn2, Decl(reverseMappedTuples1.ts, 49, 3)) + + ...with2FooPairs, +>with2FooPairs : Symbol(with2FooPairs, Decl(reverseMappedTuples1.ts, 27, 13)) + + [Bar, { bar(t) {} }], // implicit any +>Bar : Symbol(Bar, Decl(reverseMappedTuples1.ts, 18, 1)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 67, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 67, 14)) + + [Baz, { bar(t) {} }], // implicit any +>Baz : Symbol(Baz, Decl(reverseMappedTuples1.ts, 21, 1)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 68, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 68, 14)) + +]); + +declare function fn3(params: List<[...T, Foo, Foo]>): T; +>fn3 : Symbol(fn3, Decl(reverseMappedTuples1.ts, 69, 3)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 71, 21)) +>params : Symbol(params, Decl(reverseMappedTuples1.ts, 71, 46)) +>List : Symbol(List, Decl(reverseMappedTuples1.ts, 10, 50)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 71, 21)) +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 71, 21)) + +const res8 = fn3([ +>res8 : Symbol(res8, Decl(reverseMappedTuples1.ts, 73, 5)) +>fn3 : Symbol(fn3, Decl(reverseMappedTuples1.ts, 69, 3)) + + [Bar, { bar(t) {} }], +>Bar : Symbol(Bar, Decl(reverseMappedTuples1.ts, 18, 1)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 74, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 74, 14)) + + [Baz, { bar(t) {} }], +>Baz : Symbol(Baz, Decl(reverseMappedTuples1.ts, 21, 1)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 75, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 75, 14)) + + [Foo, { bar(t) {} }], +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 76, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 76, 14)) + + [Foo, { bar(t) {} }], +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 77, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 77, 14)) + +]); + +const res9 = fn3([ +>res9 : Symbol(res9, Decl(reverseMappedTuples1.ts, 80, 5)) +>fn3 : Symbol(fn3, Decl(reverseMappedTuples1.ts, 69, 3)) + + [Bar, { bar(t) {} }], +>Bar : Symbol(Bar, Decl(reverseMappedTuples1.ts, 18, 1)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 81, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 81, 14)) + + [Baz, { bar(t) {} }], +>Baz : Symbol(Baz, Decl(reverseMappedTuples1.ts, 21, 1)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 82, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 82, 14)) + + ...with2FooPairs +>with2FooPairs : Symbol(with2FooPairs, Decl(reverseMappedTuples1.ts, 27, 13)) + +]); + +const res10 = fn3([ +>res10 : Symbol(res10, Decl(reverseMappedTuples1.ts, 86, 5)) +>fn3 : Symbol(fn3, Decl(reverseMappedTuples1.ts, 69, 3)) + + [Bar, { bar(t) {} }], +>Bar : Symbol(Bar, Decl(reverseMappedTuples1.ts, 18, 1)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 87, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 87, 14)) + + [Baz, { bar(t) {} }], +>Baz : Symbol(Baz, Decl(reverseMappedTuples1.ts, 21, 1)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 88, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 88, 14)) + + ...withFooPair, +>withFooPair : Symbol(withFooPair, Decl(reverseMappedTuples1.ts, 26, 13)) + + [Foo, { bar(t) {} }], +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 90, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 90, 14)) + +]); + +const res11 = fn3([ +>res11 : Symbol(res11, Decl(reverseMappedTuples1.ts, 93, 5)) +>fn3 : Symbol(fn3, Decl(reverseMappedTuples1.ts, 69, 3)) + + [Bar, { bar(t) {} }], +>Bar : Symbol(Bar, Decl(reverseMappedTuples1.ts, 18, 1)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 94, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 94, 14)) + + [Baz, { bar(t) {} }], +>Baz : Symbol(Baz, Decl(reverseMappedTuples1.ts, 21, 1)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 95, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 95, 14)) + + [Foo, { bar(t) {} }], +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 96, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 96, 14)) + + ...withFooPair, +>withFooPair : Symbol(withFooPair, Decl(reverseMappedTuples1.ts, 26, 13)) + +]); + +declare function fn4(params: List<[Foo, Foo?, ...T]>): T; +>fn4 : Symbol(fn4, Decl(reverseMappedTuples1.ts, 98, 3)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 100, 21)) +>params : Symbol(params, Decl(reverseMappedTuples1.ts, 100, 46)) +>List : Symbol(List, Decl(reverseMappedTuples1.ts, 10, 50)) +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 100, 21)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 100, 21)) + +const res12 = fn4([ +>res12 : Symbol(res12, Decl(reverseMappedTuples1.ts, 102, 5)) +>fn4 : Symbol(fn4, Decl(reverseMappedTuples1.ts, 98, 3)) + + [Foo, { bar(t) {} }], +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 103, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 103, 14)) + + [Foo, { bar(t) {} }], +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 104, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 104, 14)) + + [Bar, { bar(t) {} }], +>Bar : Symbol(Bar, Decl(reverseMappedTuples1.ts, 18, 1)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 105, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 105, 14)) + + [Baz, { bar(t) {} }], +>Baz : Symbol(Baz, Decl(reverseMappedTuples1.ts, 21, 1)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 106, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 106, 14)) + +]); + +const res13 = fn4([ +>res13 : Symbol(res13, Decl(reverseMappedTuples1.ts, 109, 5)) +>fn4 : Symbol(fn4, Decl(reverseMappedTuples1.ts, 98, 3)) + + [Foo, { bar(t) {} }], +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 110, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 110, 14)) + + [Bar, { bar(t) {} }], // error +>Bar : Symbol(Bar, Decl(reverseMappedTuples1.ts, 18, 1)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 111, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 111, 14)) + + [Baz, { bar(t) {} }], +>Baz : Symbol(Baz, Decl(reverseMappedTuples1.ts, 21, 1)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 112, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 112, 14)) + +]); + +declare function fn5(params: List<[...T, Foo?]>): T; +>fn5 : Symbol(fn5, Decl(reverseMappedTuples1.ts, 113, 3)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 115, 21)) +>params : Symbol(params, Decl(reverseMappedTuples1.ts, 115, 46)) +>List : Symbol(List, Decl(reverseMappedTuples1.ts, 10, 50)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 115, 21)) +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 115, 21)) + +const res14 = fn5([ +>res14 : Symbol(res14, Decl(reverseMappedTuples1.ts, 117, 5)) +>fn5 : Symbol(fn5, Decl(reverseMappedTuples1.ts, 113, 3)) + + [Bar, { bar(t) {} }], +>Bar : Symbol(Bar, Decl(reverseMappedTuples1.ts, 18, 1)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 118, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 118, 14)) + + [Baz, { bar(t) {} }], +>Baz : Symbol(Baz, Decl(reverseMappedTuples1.ts, 21, 1)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 119, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 119, 14)) + + [Foo, { bar(t) {} }], +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 120, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 120, 14)) + +]); + +const res15 = fn5([ +>res15 : Symbol(res15, Decl(reverseMappedTuples1.ts, 123, 5)) +>fn5 : Symbol(fn5, Decl(reverseMappedTuples1.ts, 113, 3)) + + [Bar, { bar(t) {} }], +>Bar : Symbol(Bar, Decl(reverseMappedTuples1.ts, 18, 1)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 124, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 124, 14)) + + [Baz, { bar(t) {} }], // error, inferred [Bar, Baz] would satisfy but the checker prefers picking up trailing optional element for contextual typing etc +>Baz : Symbol(Baz, Decl(reverseMappedTuples1.ts, 21, 1)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 125, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 125, 14)) + +]); + +declare function fn6(params: List<[Foo, Foo, ...T, Foo, Foo]>): T; +>fn6 : Symbol(fn6, Decl(reverseMappedTuples1.ts, 126, 3)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 128, 21)) +>params : Symbol(params, Decl(reverseMappedTuples1.ts, 128, 46)) +>List : Symbol(List, Decl(reverseMappedTuples1.ts, 10, 50)) +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 128, 21)) +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 128, 21)) + +const res16 = fn6([ +>res16 : Symbol(res16, Decl(reverseMappedTuples1.ts, 130, 5)) +>fn6 : Symbol(fn6, Decl(reverseMappedTuples1.ts, 126, 3)) + + [Foo, { bar(t) {} }], +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 131, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 131, 14)) + + [Foo, { bar(t) {} }], +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 132, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 132, 14)) + + [Bar, { bar(t) {} }], +>Bar : Symbol(Bar, Decl(reverseMappedTuples1.ts, 18, 1)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 133, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 133, 14)) + + [Baz, { bar(t) {} }], +>Baz : Symbol(Baz, Decl(reverseMappedTuples1.ts, 21, 1)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 134, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 134, 14)) + + [Foo, { bar(t) {} }], +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 135, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 135, 14)) + + [Foo, { bar(t) {} }], +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 136, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 136, 14)) + +]); + +declare function fn7(params: List<[Foo, Foo, ...T, ...T2, Foo]>): [T, T2]; +>fn7 : Symbol(fn7, Decl(reverseMappedTuples1.ts, 137, 3)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 139, 21)) +>T2 : Symbol(T2, Decl(reverseMappedTuples1.ts, 139, 45)) +>params : Symbol(params, Decl(reverseMappedTuples1.ts, 139, 72)) +>List : Symbol(List, Decl(reverseMappedTuples1.ts, 10, 50)) +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 139, 21)) +>T2 : Symbol(T2, Decl(reverseMappedTuples1.ts, 139, 45)) +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 139, 21)) +>T2 : Symbol(T2, Decl(reverseMappedTuples1.ts, 139, 45)) + +const res17 = fn7([ +>res17 : Symbol(res17, Decl(reverseMappedTuples1.ts, 141, 5)) +>fn7 : Symbol(fn7, Decl(reverseMappedTuples1.ts, 137, 3)) + + [Foo, { bar(t) {} }], +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 142, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 142, 14)) + + [Foo, { bar(t) {} }], +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 143, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 143, 14)) + + [Bar, { bar(t) {} }], // implicit any +>Bar : Symbol(Bar, Decl(reverseMappedTuples1.ts, 18, 1)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 144, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 144, 14)) + + [Baz, { bar(t) {} }], // implicit any +>Baz : Symbol(Baz, Decl(reverseMappedTuples1.ts, 21, 1)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 145, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 145, 14)) + + [Foo, { bar(t) {} }], // implicit any +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 146, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 146, 14)) + + [Foo, { bar(t) {} }], +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 147, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 147, 14)) + +]); + +declare function fn8(params: List<[Foo, Foo, ...T, ...Foo[]]>): T; +>fn8 : Symbol(fn8, Decl(reverseMappedTuples1.ts, 148, 3)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 150, 21)) +>params : Symbol(params, Decl(reverseMappedTuples1.ts, 150, 46)) +>List : Symbol(List, Decl(reverseMappedTuples1.ts, 10, 50)) +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 150, 21)) +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>T : Symbol(T, Decl(reverseMappedTuples1.ts, 150, 21)) + +const res18 = fn8([ +>res18 : Symbol(res18, Decl(reverseMappedTuples1.ts, 152, 5)) +>fn8 : Symbol(fn8, Decl(reverseMappedTuples1.ts, 148, 3)) + + [Foo, { bar(t) {} }], +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 153, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 153, 14)) + + [Foo, { bar(t) {} }], +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 154, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 154, 14)) + + [Bar, { bar(t) {} }], // implicit any +>Bar : Symbol(Bar, Decl(reverseMappedTuples1.ts, 18, 1)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 155, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 155, 14)) + + [Baz, { bar(t) {} }], // implicit any +>Baz : Symbol(Baz, Decl(reverseMappedTuples1.ts, 21, 1)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 156, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 156, 14)) + + [Foo, { bar(t) {} }], // implicit any +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 157, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 157, 14)) + + [Foo, { bar(t) {} }], // implicit any +>Foo : Symbol(Foo, Decl(reverseMappedTuples1.ts, 14, 2)) +>bar : Symbol(bar, Decl(reverseMappedTuples1.ts, 158, 9)) +>t : Symbol(t, Decl(reverseMappedTuples1.ts, 158, 14)) + +]); + diff --git a/tests/baselines/reference/reverseMappedTuples1.types b/tests/baselines/reference/reverseMappedTuples1.types new file mode 100644 index 0000000000000..11018161a230b --- /dev/null +++ b/tests/baselines/reference/reverseMappedTuples1.types @@ -0,0 +1,1031 @@ +//// [tests/cases/compiler/reverseMappedTuples1.ts] //// + +=== Performance Stats === +Type Count: 2,500 +Instantiation count: 2,500 + +=== reverseMappedTuples1.ts === +// https://github.com/microsoft/TypeScript/issues/58726 + +type Constructor = { +>Constructor : Constructor +> : ^^^^^^^^^^^^^^ + + new (...args: never[]): T; +>args : never[] +> : ^^^^^^^ + +}; + +interface GenericParams { + bar: (t: T) => void; +>bar : (t: T) => void +> : ^ ^^ ^^^^^ +>t : T +> : ^ +} + +type Pair = [Constructor, GenericParams]; +>Pair : Pair +> : ^^^^^^^ + +type List = { +>List : List +> : ^^^^^^^ + + [K in keyof T]: Pair; +}; + +class Foo { +>Foo : Foo +> : ^^^ + + test() {} +>test : () => void +> : ^^^^^^^^^^ +} +class Bar { +>Bar : Bar +> : ^^^ + + other() {} +>other : () => void +> : ^^^^^^^^^^ +} +class Baz { +>Baz : Baz +> : ^^^ + + third() {} +>third : () => void +> : ^^^^^^^^^^ +} + +declare const withFooPair: [Pair]; +>withFooPair : [Pair] +> : ^^^^^^^^^^^ + +declare const with2FooPairs: [Pair, Pair]; +>with2FooPairs : [Pair, Pair] +> : ^^^^^^^^^^^^^^^^^^^^^^ + +declare function fn1(params: List<[...T]>): T; +>fn1 : (params: List<[...T]>) => T +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>params : [...List] +> : ^^^^^^^^^^^^ + +const res1 = fn1([ +>res1 : [Foo, Bar] +> : ^^^^^^^^^^ +>fn1([ [Foo, { bar(t) {} }], [Bar, { bar(t) {} }],]) : [Foo, Bar] +> : ^^^^^^^^^^ +>fn1 : (params: List<[...T]>) => T +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>[ [Foo, { bar(t) {} }], [Bar, { bar(t) {} }],] : [[typeof Foo, { bar(t: Foo): void; }], [typeof Bar, { bar(t: Bar): void; }]] +> : ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ + + [Foo, { bar(t) {} }], +>[Foo, { bar(t) {} }] : [typeof Foo, { bar(t: Foo): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Foo : typeof Foo +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Foo): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Foo) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Foo +> : ^^^ + + [Bar, { bar(t) {} }], +>[Bar, { bar(t) {} }] : [typeof Bar, { bar(t: Bar): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Bar : typeof Bar +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Bar): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Bar) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Bar +> : ^^^ + +]); + +const res2 = fn1([ +>res2 : [Foo, Bar] +> : ^^^^^^^^^^ +>fn1([ ...withFooPair, [Bar, { bar(t) {} }], // implicit any]) : [Foo, Bar] +> : ^^^^^^^^^^ +>fn1 : (params: List<[...T]>) => T +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>[ ...withFooPair, [Bar, { bar(t) {} }], // implicit any] : [Pair, [typeof Bar, { bar(t: any): void; }]] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ + + ...withFooPair, +>...withFooPair : Pair +> : ^^^^^^^^^ +>withFooPair : [Pair] +> : ^^^^^^^^^^^ + + [Bar, { bar(t) {} }], // implicit any +>[Bar, { bar(t) {} }] : [typeof Bar, { bar(t: any): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Bar : typeof Bar +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: any): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: any) => void +> : ^ ^^^^^^^^^^^^^^ +>t : any +> : ^^^ + +]); + +const res3 = fn1([ +>res3 : [Foo, Foo, Bar] +> : ^^^^^^^^^^^^^^^ +>fn1([ ...with2FooPairs, [Bar, { bar(t) {} }], // implicit any]) : [Foo, Foo, Bar] +> : ^^^^^^^^^^^^^^^ +>fn1 : (params: List<[...T]>) => T +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>[ ...with2FooPairs, [Bar, { bar(t) {} }], // implicit any] : [Pair, Pair, [typeof Bar, { bar(t: any): void; }]] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ + + ...with2FooPairs, +>...with2FooPairs : Pair +> : ^^^^^^^^^ +>with2FooPairs : [Pair, Pair] +> : ^^^^^^^^^^^^^^^^^^^^^^ + + [Bar, { bar(t) {} }], // implicit any +>[Bar, { bar(t) {} }] : [typeof Bar, { bar(t: any): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Bar : typeof Bar +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: any): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: any) => void +> : ^ ^^^^^^^^^^^^^^ +>t : any +> : ^^^ + +]); + +const res4 = fn1([ +>res4 : [Bar, Foo, Foo] +> : ^^^^^^^^^^^^^^^ +>fn1([ [Bar, { bar(t) {} }], ...with2FooPairs,]) : [Bar, Foo, Foo] +> : ^^^^^^^^^^^^^^^ +>fn1 : (params: List<[...T]>) => T +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>[ [Bar, { bar(t) {} }], ...with2FooPairs,] : [[typeof Bar, { bar(t: Bar): void; }], Pair, Pair] +> : ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + [Bar, { bar(t) {} }], +>[Bar, { bar(t) {} }] : [typeof Bar, { bar(t: Bar): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Bar : typeof Bar +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Bar): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Bar) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Bar +> : ^^^ + + ...with2FooPairs, +>...with2FooPairs : Pair +> : ^^^^^^^^^ +>with2FooPairs : [Pair, Pair] +> : ^^^^^^^^^^^^^^^^^^^^^^ + +]); + +declare function fn2(params: List<[Foo, Foo, ...T]>): T; +>fn2 : (params: List<[Foo, Foo, ...T]>) => T +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>params : [Pair, Pair, ...List] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +const res5 = fn2([ +>res5 : [Bar, Baz] +> : ^^^^^^^^^^ +>fn2([ [Foo, { bar(t) {} }], [Foo, { bar(t) {} }], [Bar, { bar(t) {} }], [Baz, { bar(t) {} }],]) : [Bar, Baz] +> : ^^^^^^^^^^ +>fn2 : (params: List<[Foo, Foo, ...T]>) => T +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>[ [Foo, { bar(t) {} }], [Foo, { bar(t) {} }], [Bar, { bar(t) {} }], [Baz, { bar(t) {} }],] : [[typeof Foo, { bar(t: Foo): void; }], [typeof Foo, { bar(t: Foo): void; }], [typeof Bar, { bar(t: Bar): void; }], [typeof Baz, { bar(t: Baz): void; }]] +> : ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ + + [Foo, { bar(t) {} }], +>[Foo, { bar(t) {} }] : [typeof Foo, { bar(t: Foo): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Foo : typeof Foo +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Foo): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Foo) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Foo +> : ^^^ + + [Foo, { bar(t) {} }], +>[Foo, { bar(t) {} }] : [typeof Foo, { bar(t: Foo): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Foo : typeof Foo +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Foo): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Foo) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Foo +> : ^^^ + + [Bar, { bar(t) {} }], +>[Bar, { bar(t) {} }] : [typeof Bar, { bar(t: Bar): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Bar : typeof Bar +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Bar): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Bar) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Bar +> : ^^^ + + [Baz, { bar(t) {} }], +>[Baz, { bar(t) {} }] : [typeof Baz, { bar(t: Baz): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Baz : typeof Baz +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Baz): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Baz) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Baz +> : ^^^ + +]); + +const res6 = fn2([ +>res6 : [Bar] +> : ^^^^^ +>fn2([ ...with2FooPairs, [Bar, { bar(t) {} }], // implicit any]) : [Bar] +> : ^^^^^ +>fn2 : (params: List<[Foo, Foo, ...T]>) => T +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>[ ...with2FooPairs, [Bar, { bar(t) {} }], // implicit any] : [Pair, Pair, [typeof Bar, { bar(t: any): void; }]] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ + + ...with2FooPairs, +>...with2FooPairs : Pair +> : ^^^^^^^^^ +>with2FooPairs : [Pair, Pair] +> : ^^^^^^^^^^^^^^^^^^^^^^ + + [Bar, { bar(t) {} }], // implicit any +>[Bar, { bar(t) {} }] : [typeof Bar, { bar(t: any): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Bar : typeof Bar +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: any): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: any) => void +> : ^ ^^^^^^^^^^^^^^ +>t : any +> : ^^^ + +]); + +const res7 = fn2([ +>res7 : [Bar, Baz] +> : ^^^^^^^^^^ +>fn2([ ...with2FooPairs, [Bar, { bar(t) {} }], // implicit any [Baz, { bar(t) {} }], // implicit any]) : [Bar, Baz] +> : ^^^^^^^^^^ +>fn2 : (params: List<[Foo, Foo, ...T]>) => T +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>[ ...with2FooPairs, [Bar, { bar(t) {} }], // implicit any [Baz, { bar(t) {} }], // implicit any] : [Pair, Pair, [typeof Bar, { bar(t: any): void; }], [typeof Baz, { bar(t: any): void; }]] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ + + ...with2FooPairs, +>...with2FooPairs : Pair +> : ^^^^^^^^^ +>with2FooPairs : [Pair, Pair] +> : ^^^^^^^^^^^^^^^^^^^^^^ + + [Bar, { bar(t) {} }], // implicit any +>[Bar, { bar(t) {} }] : [typeof Bar, { bar(t: any): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Bar : typeof Bar +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: any): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: any) => void +> : ^ ^^^^^^^^^^^^^^ +>t : any +> : ^^^ + + [Baz, { bar(t) {} }], // implicit any +>[Baz, { bar(t) {} }] : [typeof Baz, { bar(t: any): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Baz : typeof Baz +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: any): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: any) => void +> : ^ ^^^^^^^^^^^^^^ +>t : any +> : ^^^ + +]); + +declare function fn3(params: List<[...T, Foo, Foo]>): T; +>fn3 : (params: List<[...T, Foo, Foo]>) => T +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>params : [...List, Pair, Pair] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +const res8 = fn3([ +>res8 : [Bar, Baz] +> : ^^^^^^^^^^ +>fn3([ [Bar, { bar(t) {} }], [Baz, { bar(t) {} }], [Foo, { bar(t) {} }], [Foo, { bar(t) {} }],]) : [Bar, Baz] +> : ^^^^^^^^^^ +>fn3 : (params: List<[...T, Foo, Foo]>) => T +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>[ [Bar, { bar(t) {} }], [Baz, { bar(t) {} }], [Foo, { bar(t) {} }], [Foo, { bar(t) {} }],] : [[typeof Bar, { bar(t: Bar): void; }], [typeof Baz, { bar(t: Baz): void; }], [typeof Foo, { bar(t: Foo): void; }], [typeof Foo, { bar(t: Foo): void; }]] +> : ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ + + [Bar, { bar(t) {} }], +>[Bar, { bar(t) {} }] : [typeof Bar, { bar(t: Bar): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Bar : typeof Bar +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Bar): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Bar) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Bar +> : ^^^ + + [Baz, { bar(t) {} }], +>[Baz, { bar(t) {} }] : [typeof Baz, { bar(t: Baz): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Baz : typeof Baz +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Baz): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Baz) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Baz +> : ^^^ + + [Foo, { bar(t) {} }], +>[Foo, { bar(t) {} }] : [typeof Foo, { bar(t: Foo): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Foo : typeof Foo +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Foo): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Foo) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Foo +> : ^^^ + + [Foo, { bar(t) {} }], +>[Foo, { bar(t) {} }] : [typeof Foo, { bar(t: Foo): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Foo : typeof Foo +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Foo): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Foo) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Foo +> : ^^^ + +]); + +const res9 = fn3([ +>res9 : [Bar, Baz] +> : ^^^^^^^^^^ +>fn3([ [Bar, { bar(t) {} }], [Baz, { bar(t) {} }], ...with2FooPairs]) : [Bar, Baz] +> : ^^^^^^^^^^ +>fn3 : (params: List<[...T, Foo, Foo]>) => T +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>[ [Bar, { bar(t) {} }], [Baz, { bar(t) {} }], ...with2FooPairs] : [[typeof Bar, { bar(t: Bar): void; }], [typeof Baz, { bar(t: Baz): void; }], Pair, Pair] +> : ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + [Bar, { bar(t) {} }], +>[Bar, { bar(t) {} }] : [typeof Bar, { bar(t: Bar): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Bar : typeof Bar +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Bar): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Bar) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Bar +> : ^^^ + + [Baz, { bar(t) {} }], +>[Baz, { bar(t) {} }] : [typeof Baz, { bar(t: Baz): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Baz : typeof Baz +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Baz): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Baz) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Baz +> : ^^^ + + ...with2FooPairs +>...with2FooPairs : Pair +> : ^^^^^^^^^ +>with2FooPairs : [Pair, Pair] +> : ^^^^^^^^^^^^^^^^^^^^^^ + +]); + +const res10 = fn3([ +>res10 : [Bar, Baz] +> : ^^^^^^^^^^ +>fn3([ [Bar, { bar(t) {} }], [Baz, { bar(t) {} }], ...withFooPair, [Foo, { bar(t) {} }],]) : [Bar, Baz] +> : ^^^^^^^^^^ +>fn3 : (params: List<[...T, Foo, Foo]>) => T +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>[ [Bar, { bar(t) {} }], [Baz, { bar(t) {} }], ...withFooPair, [Foo, { bar(t) {} }],] : [[typeof Bar, { bar(t: Bar): void; }], [typeof Baz, { bar(t: Baz): void; }], Pair, [typeof Foo, { bar(t: Foo): void; }]] +> : ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ + + [Bar, { bar(t) {} }], +>[Bar, { bar(t) {} }] : [typeof Bar, { bar(t: Bar): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Bar : typeof Bar +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Bar): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Bar) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Bar +> : ^^^ + + [Baz, { bar(t) {} }], +>[Baz, { bar(t) {} }] : [typeof Baz, { bar(t: Baz): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Baz : typeof Baz +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Baz): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Baz) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Baz +> : ^^^ + + ...withFooPair, +>...withFooPair : Pair +> : ^^^^^^^^^ +>withFooPair : [Pair] +> : ^^^^^^^^^^^ + + [Foo, { bar(t) {} }], +>[Foo, { bar(t) {} }] : [typeof Foo, { bar(t: Foo): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Foo : typeof Foo +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Foo): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Foo) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Foo +> : ^^^ + +]); + +const res11 = fn3([ +>res11 : [Bar, Baz] +> : ^^^^^^^^^^ +>fn3([ [Bar, { bar(t) {} }], [Baz, { bar(t) {} }], [Foo, { bar(t) {} }], ...withFooPair,]) : [Bar, Baz] +> : ^^^^^^^^^^ +>fn3 : (params: List<[...T, Foo, Foo]>) => T +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>[ [Bar, { bar(t) {} }], [Baz, { bar(t) {} }], [Foo, { bar(t) {} }], ...withFooPair,] : [[typeof Bar, { bar(t: Bar): void; }], [typeof Baz, { bar(t: Baz): void; }], [typeof Foo, { bar(t: any): void; }], Pair] +> : ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + [Bar, { bar(t) {} }], +>[Bar, { bar(t) {} }] : [typeof Bar, { bar(t: Bar): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Bar : typeof Bar +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Bar): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Bar) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Bar +> : ^^^ + + [Baz, { bar(t) {} }], +>[Baz, { bar(t) {} }] : [typeof Baz, { bar(t: Baz): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Baz : typeof Baz +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Baz): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Baz) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Baz +> : ^^^ + + [Foo, { bar(t) {} }], +>[Foo, { bar(t) {} }] : [typeof Foo, { bar(t: any): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Foo : typeof Foo +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: any): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: any) => void +> : ^ ^^^^^^^^^^^^^^ +>t : any +> : ^^^ + + ...withFooPair, +>...withFooPair : Pair +> : ^^^^^^^^^ +>withFooPair : [Pair] +> : ^^^^^^^^^^^ + +]); + +declare function fn4(params: List<[Foo, Foo?, ...T]>): T; +>fn4 : (params: List<[Foo, Foo?, ...T]>) => T +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>params : [Pair, (Pair | undefined)?, ...List] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +const res12 = fn4([ +>res12 : [Bar, Baz] +> : ^^^^^^^^^^ +>fn4([ [Foo, { bar(t) {} }], [Foo, { bar(t) {} }], [Bar, { bar(t) {} }], [Baz, { bar(t) {} }],]) : [Bar, Baz] +> : ^^^^^^^^^^ +>fn4 : (params: List<[Foo, Foo?, ...T]>) => T +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>[ [Foo, { bar(t) {} }], [Foo, { bar(t) {} }], [Bar, { bar(t) {} }], [Baz, { bar(t) {} }],] : [[typeof Foo, { bar(t: Foo): void; }], [typeof Foo, { bar(t: Foo | undefined): void; }], [typeof Bar, { bar(t: Bar): void; }], [typeof Baz, { bar(t: Baz): void; }]] +> : ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ + + [Foo, { bar(t) {} }], +>[Foo, { bar(t) {} }] : [typeof Foo, { bar(t: Foo): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Foo : typeof Foo +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Foo): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Foo) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Foo +> : ^^^ + + [Foo, { bar(t) {} }], +>[Foo, { bar(t) {} }] : [typeof Foo, { bar(t: Foo | undefined): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Foo : typeof Foo +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Foo | undefined): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>bar : (t: Foo | undefined) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>t : Foo | undefined +> : ^^^^^^^^^^^^^^^ + + [Bar, { bar(t) {} }], +>[Bar, { bar(t) {} }] : [typeof Bar, { bar(t: Bar): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Bar : typeof Bar +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Bar): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Bar) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Bar +> : ^^^ + + [Baz, { bar(t) {} }], +>[Baz, { bar(t) {} }] : [typeof Baz, { bar(t: Baz): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Baz : typeof Baz +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Baz): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Baz) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Baz +> : ^^^ + +]); + +const res13 = fn4([ +>res13 : [Baz] +> : ^^^^^ +>fn4([ [Foo, { bar(t) {} }], [Bar, { bar(t) {} }], // error [Baz, { bar(t) {} }],]) : [Baz] +> : ^^^^^ +>fn4 : (params: List<[Foo, Foo?, ...T]>) => T +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>[ [Foo, { bar(t) {} }], [Bar, { bar(t) {} }], // error [Baz, { bar(t) {} }],] : [[typeof Foo, { bar(t: Foo): void; }], [typeof Bar, { bar(t: Foo | undefined): void; }], [typeof Baz, { bar(t: Baz): void; }]] +> : ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ + + [Foo, { bar(t) {} }], +>[Foo, { bar(t) {} }] : [typeof Foo, { bar(t: Foo): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Foo : typeof Foo +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Foo): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Foo) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Foo +> : ^^^ + + [Bar, { bar(t) {} }], // error +>[Bar, { bar(t) {} }] : [typeof Bar, { bar(t: Foo | undefined): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Bar : typeof Bar +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Foo | undefined): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>bar : (t: Foo | undefined) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>t : Foo | undefined +> : ^^^^^^^^^^^^^^^ + + [Baz, { bar(t) {} }], +>[Baz, { bar(t) {} }] : [typeof Baz, { bar(t: Baz): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Baz : typeof Baz +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Baz): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Baz) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Baz +> : ^^^ + +]); + +declare function fn5(params: List<[...T, Foo?]>): T; +>fn5 : (params: List<[...T, Foo?]>) => T +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>params : [...List, (Pair | undefined)?] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +const res14 = fn5([ +>res14 : [Bar, Baz] +> : ^^^^^^^^^^ +>fn5([ [Bar, { bar(t) {} }], [Baz, { bar(t) {} }], [Foo, { bar(t) {} }],]) : [Bar, Baz] +> : ^^^^^^^^^^ +>fn5 : (params: List<[...T, Foo?]>) => T +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>[ [Bar, { bar(t) {} }], [Baz, { bar(t) {} }], [Foo, { bar(t) {} }],] : [[typeof Bar, { bar(t: Bar): void; }], [typeof Baz, { bar(t: Baz): void; }], [typeof Foo, { bar(t: Foo | undefined): void; }]] +> : ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + [Bar, { bar(t) {} }], +>[Bar, { bar(t) {} }] : [typeof Bar, { bar(t: Bar): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Bar : typeof Bar +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Bar): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Bar) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Bar +> : ^^^ + + [Baz, { bar(t) {} }], +>[Baz, { bar(t) {} }] : [typeof Baz, { bar(t: Baz): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Baz : typeof Baz +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Baz): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Baz) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Baz +> : ^^^ + + [Foo, { bar(t) {} }], +>[Foo, { bar(t) {} }] : [typeof Foo, { bar(t: Foo | undefined): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Foo : typeof Foo +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Foo | undefined): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>bar : (t: Foo | undefined) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>t : Foo | undefined +> : ^^^^^^^^^^^^^^^ + +]); + +const res15 = fn5([ +>res15 : [Bar] +> : ^^^^^ +>fn5([ [Bar, { bar(t) {} }], [Baz, { bar(t) {} }], // error, inferred [Bar, Baz] would satisfy but the checker prefers picking up trailing optional element for contextual typing etc]) : [Bar] +> : ^^^^^ +>fn5 : (params: List<[...T, Foo?]>) => T +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>[ [Bar, { bar(t) {} }], [Baz, { bar(t) {} }], // error, inferred [Bar, Baz] would satisfy but the checker prefers picking up trailing optional element for contextual typing etc] : [[typeof Bar, { bar(t: Bar): void; }], [typeof Baz, { bar(t: Foo | undefined): void; }]] +> : ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + [Bar, { bar(t) {} }], +>[Bar, { bar(t) {} }] : [typeof Bar, { bar(t: Bar): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Bar : typeof Bar +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Bar): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Bar) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Bar +> : ^^^ + + [Baz, { bar(t) {} }], // error, inferred [Bar, Baz] would satisfy but the checker prefers picking up trailing optional element for contextual typing etc +>[Baz, { bar(t) {} }] : [typeof Baz, { bar(t: Foo | undefined): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Baz : typeof Baz +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Foo | undefined): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>bar : (t: Foo | undefined) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>t : Foo | undefined +> : ^^^^^^^^^^^^^^^ + +]); + +declare function fn6(params: List<[Foo, Foo, ...T, Foo, Foo]>): T; +>fn6 : (params: List<[Foo, Foo, ...T, Foo, Foo]>) => T +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>params : [Pair, Pair, ...List, Pair, Pair] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +const res16 = fn6([ +>res16 : [Bar, Baz] +> : ^^^^^^^^^^ +>fn6([ [Foo, { bar(t) {} }], [Foo, { bar(t) {} }], [Bar, { bar(t) {} }], [Baz, { bar(t) {} }], [Foo, { bar(t) {} }], [Foo, { bar(t) {} }],]) : [Bar, Baz] +> : ^^^^^^^^^^ +>fn6 : (params: List<[Foo, Foo, ...T, Foo, Foo]>) => T +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>[ [Foo, { bar(t) {} }], [Foo, { bar(t) {} }], [Bar, { bar(t) {} }], [Baz, { bar(t) {} }], [Foo, { bar(t) {} }], [Foo, { bar(t) {} }],] : [[typeof Foo, { bar(t: Foo): void; }], [typeof Foo, { bar(t: Foo): void; }], [typeof Bar, { bar(t: Bar): void; }], [typeof Baz, { bar(t: Baz): void; }], [typeof Foo, { bar(t: Foo): void; }], [typeof Foo, { bar(t: Foo): void; }]] +> : ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ + + [Foo, { bar(t) {} }], +>[Foo, { bar(t) {} }] : [typeof Foo, { bar(t: Foo): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Foo : typeof Foo +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Foo): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Foo) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Foo +> : ^^^ + + [Foo, { bar(t) {} }], +>[Foo, { bar(t) {} }] : [typeof Foo, { bar(t: Foo): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Foo : typeof Foo +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Foo): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Foo) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Foo +> : ^^^ + + [Bar, { bar(t) {} }], +>[Bar, { bar(t) {} }] : [typeof Bar, { bar(t: Bar): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Bar : typeof Bar +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Bar): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Bar) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Bar +> : ^^^ + + [Baz, { bar(t) {} }], +>[Baz, { bar(t) {} }] : [typeof Baz, { bar(t: Baz): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Baz : typeof Baz +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Baz): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Baz) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Baz +> : ^^^ + + [Foo, { bar(t) {} }], +>[Foo, { bar(t) {} }] : [typeof Foo, { bar(t: Foo): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Foo : typeof Foo +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Foo): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Foo) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Foo +> : ^^^ + + [Foo, { bar(t) {} }], +>[Foo, { bar(t) {} }] : [typeof Foo, { bar(t: Foo): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Foo : typeof Foo +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Foo): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Foo) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Foo +> : ^^^ + +]); + +declare function fn7(params: List<[Foo, Foo, ...T, ...T2, Foo]>): [T, T2]; +>fn7 : (params: List<[Foo, Foo, ...T, ...T2, Foo]>) => [T, T2] +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>params : [Pair, Pair, ...List, ...List, Pair] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +const res17 = fn7([ +>res17 : [readonly {}[], readonly {}[]] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>fn7([ [Foo, { bar(t) {} }], [Foo, { bar(t) {} }], [Bar, { bar(t) {} }], // implicit any [Baz, { bar(t) {} }], // implicit any [Foo, { bar(t) {} }], // implicit any [Foo, { bar(t) {} }],]) : [readonly {}[], readonly {}[]] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>fn7 : (params: List<[Foo, Foo, ...T, ...T2, Foo]>) => [T, T2] +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>[ [Foo, { bar(t) {} }], [Foo, { bar(t) {} }], [Bar, { bar(t) {} }], // implicit any [Baz, { bar(t) {} }], // implicit any [Foo, { bar(t) {} }], // implicit any [Foo, { bar(t) {} }],] : [[typeof Foo, { bar(t: Foo): void; }], [typeof Foo, { bar(t: Foo): void; }], [typeof Bar, { bar(t: any): void; }], [typeof Baz, { bar(t: any): void; }], [typeof Foo, { bar(t: any): void; }], [typeof Foo, { bar(t: Foo): void; }]] +> : ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ + + [Foo, { bar(t) {} }], +>[Foo, { bar(t) {} }] : [typeof Foo, { bar(t: Foo): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Foo : typeof Foo +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Foo): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Foo) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Foo +> : ^^^ + + [Foo, { bar(t) {} }], +>[Foo, { bar(t) {} }] : [typeof Foo, { bar(t: Foo): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Foo : typeof Foo +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Foo): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Foo) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Foo +> : ^^^ + + [Bar, { bar(t) {} }], // implicit any +>[Bar, { bar(t) {} }] : [typeof Bar, { bar(t: any): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Bar : typeof Bar +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: any): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: any) => void +> : ^ ^^^^^^^^^^^^^^ +>t : any +> : ^^^ + + [Baz, { bar(t) {} }], // implicit any +>[Baz, { bar(t) {} }] : [typeof Baz, { bar(t: any): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Baz : typeof Baz +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: any): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: any) => void +> : ^ ^^^^^^^^^^^^^^ +>t : any +> : ^^^ + + [Foo, { bar(t) {} }], // implicit any +>[Foo, { bar(t) {} }] : [typeof Foo, { bar(t: any): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Foo : typeof Foo +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: any): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: any) => void +> : ^ ^^^^^^^^^^^^^^ +>t : any +> : ^^^ + + [Foo, { bar(t) {} }], +>[Foo, { bar(t) {} }] : [typeof Foo, { bar(t: Foo): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Foo : typeof Foo +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Foo): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Foo) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Foo +> : ^^^ + +]); + +declare function fn8(params: List<[Foo, Foo, ...T, ...Foo[]]>): T; +>fn8 : (params: List<[Foo, Foo, ...T, ...Foo[]]>) => T +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>params : [Pair, Pair, ...List, ...Pair[]] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +const res18 = fn8([ +>res18 : readonly {}[] +> : ^^^^^^^^^^^^^ +>fn8([ [Foo, { bar(t) {} }], [Foo, { bar(t) {} }], [Bar, { bar(t) {} }], // implicit any [Baz, { bar(t) {} }], // implicit any [Foo, { bar(t) {} }], // implicit any [Foo, { bar(t) {} }], // implicit any]) : readonly {}[] +> : ^^^^^^^^^^^^^ +>fn8 : (params: List<[Foo, Foo, ...T, ...Foo[]]>) => T +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>[ [Foo, { bar(t) {} }], [Foo, { bar(t) {} }], [Bar, { bar(t) {} }], // implicit any [Baz, { bar(t) {} }], // implicit any [Foo, { bar(t) {} }], // implicit any [Foo, { bar(t) {} }], // implicit any] : [[typeof Foo, { bar(t: Foo): void; }], [typeof Foo, { bar(t: Foo): void; }], [typeof Bar, { bar(t: any): void; }], [typeof Baz, { bar(t: any): void; }], [typeof Foo, { bar(t: any): void; }], [typeof Foo, { bar(t: any): void; }]] +> : ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ + + [Foo, { bar(t) {} }], +>[Foo, { bar(t) {} }] : [typeof Foo, { bar(t: Foo): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Foo : typeof Foo +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Foo): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Foo) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Foo +> : ^^^ + + [Foo, { bar(t) {} }], +>[Foo, { bar(t) {} }] : [typeof Foo, { bar(t: Foo): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Foo : typeof Foo +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: Foo): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: Foo) => void +> : ^ ^^^^^^^^^^^^^^ +>t : Foo +> : ^^^ + + [Bar, { bar(t) {} }], // implicit any +>[Bar, { bar(t) {} }] : [typeof Bar, { bar(t: any): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Bar : typeof Bar +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: any): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: any) => void +> : ^ ^^^^^^^^^^^^^^ +>t : any +> : ^^^ + + [Baz, { bar(t) {} }], // implicit any +>[Baz, { bar(t) {} }] : [typeof Baz, { bar(t: any): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Baz : typeof Baz +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: any): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: any) => void +> : ^ ^^^^^^^^^^^^^^ +>t : any +> : ^^^ + + [Foo, { bar(t) {} }], // implicit any +>[Foo, { bar(t) {} }] : [typeof Foo, { bar(t: any): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Foo : typeof Foo +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: any): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: any) => void +> : ^ ^^^^^^^^^^^^^^ +>t : any +> : ^^^ + + [Foo, { bar(t) {} }], // implicit any +>[Foo, { bar(t) {} }] : [typeof Foo, { bar(t: any): void; }] +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>Foo : typeof Foo +> : ^^^^^^^^^^ +>{ bar(t) {} } : { bar(t: any): void; } +> : ^^^^^^ ^^^^^^^^^^^^^^^ +>bar : (t: any) => void +> : ^ ^^^^^^^^^^^^^^ +>t : any +> : ^^^ + +]); + diff --git a/tests/cases/compiler/reverseMappedTuples1.ts b/tests/cases/compiler/reverseMappedTuples1.ts new file mode 100644 index 0000000000000..f1925d2585fa9 --- /dev/null +++ b/tests/cases/compiler/reverseMappedTuples1.ts @@ -0,0 +1,163 @@ +// @strict: true +// @noEmit: true + +// https://github.com/microsoft/TypeScript/issues/58726 + +type Constructor = { + new (...args: never[]): T; +}; + +interface GenericParams { + bar: (t: T) => void; +} + +type Pair = [Constructor, GenericParams]; + +type List = { + [K in keyof T]: Pair; +}; + +class Foo { + test() {} +} +class Bar { + other() {} +} +class Baz { + third() {} +} + +declare const withFooPair: [Pair]; +declare const with2FooPairs: [Pair, Pair]; + +declare function fn1(params: List<[...T]>): T; + +const res1 = fn1([ + [Foo, { bar(t) {} }], + [Bar, { bar(t) {} }], +]); + +const res2 = fn1([ + ...withFooPair, + [Bar, { bar(t) {} }], // implicit any +]); + +const res3 = fn1([ + ...with2FooPairs, + [Bar, { bar(t) {} }], // implicit any +]); + +const res4 = fn1([ + [Bar, { bar(t) {} }], + ...with2FooPairs, +]); + +declare function fn2(params: List<[Foo, Foo, ...T]>): T; + +const res5 = fn2([ + [Foo, { bar(t) {} }], + [Foo, { bar(t) {} }], + [Bar, { bar(t) {} }], + [Baz, { bar(t) {} }], +]); + +const res6 = fn2([ + ...with2FooPairs, + [Bar, { bar(t) {} }], // implicit any +]); + +const res7 = fn2([ + ...with2FooPairs, + [Bar, { bar(t) {} }], // implicit any + [Baz, { bar(t) {} }], // implicit any +]); + +declare function fn3(params: List<[...T, Foo, Foo]>): T; + +const res8 = fn3([ + [Bar, { bar(t) {} }], + [Baz, { bar(t) {} }], + [Foo, { bar(t) {} }], + [Foo, { bar(t) {} }], +]); + +const res9 = fn3([ + [Bar, { bar(t) {} }], + [Baz, { bar(t) {} }], + ...with2FooPairs +]); + +const res10 = fn3([ + [Bar, { bar(t) {} }], + [Baz, { bar(t) {} }], + ...withFooPair, + [Foo, { bar(t) {} }], +]); + +const res11 = fn3([ + [Bar, { bar(t) {} }], + [Baz, { bar(t) {} }], + [Foo, { bar(t) {} }], + ...withFooPair, +]); + +declare function fn4(params: List<[Foo, Foo?, ...T]>): T; + +const res12 = fn4([ + [Foo, { bar(t) {} }], + [Foo, { bar(t) {} }], + [Bar, { bar(t) {} }], + [Baz, { bar(t) {} }], +]); + +const res13 = fn4([ + [Foo, { bar(t) {} }], + [Bar, { bar(t) {} }], // error + [Baz, { bar(t) {} }], +]); + +declare function fn5(params: List<[...T, Foo?]>): T; + +const res14 = fn5([ + [Bar, { bar(t) {} }], + [Baz, { bar(t) {} }], + [Foo, { bar(t) {} }], +]); + +const res15 = fn5([ + [Bar, { bar(t) {} }], + [Baz, { bar(t) {} }], // error, inferred [Bar, Baz] would satisfy but the checker prefers picking up trailing optional element for contextual typing etc +]); + +declare function fn6(params: List<[Foo, Foo, ...T, Foo, Foo]>): T; + +const res16 = fn6([ + [Foo, { bar(t) {} }], + [Foo, { bar(t) {} }], + [Bar, { bar(t) {} }], + [Baz, { bar(t) {} }], + [Foo, { bar(t) {} }], + [Foo, { bar(t) {} }], +]); + +declare function fn7(params: List<[Foo, Foo, ...T, ...T2, Foo]>): [T, T2]; + +const res17 = fn7([ + [Foo, { bar(t) {} }], + [Foo, { bar(t) {} }], + [Bar, { bar(t) {} }], // implicit any + [Baz, { bar(t) {} }], // implicit any + [Foo, { bar(t) {} }], // implicit any + [Foo, { bar(t) {} }], +]); + +declare function fn8(params: List<[Foo, Foo, ...T, ...Foo[]]>): T; + +const res18 = fn8([ + [Foo, { bar(t) {} }], + [Foo, { bar(t) {} }], + [Bar, { bar(t) {} }], // implicit any + [Baz, { bar(t) {} }], // implicit any + [Foo, { bar(t) {} }], // implicit any + [Foo, { bar(t) {} }], // implicit any +]);