|
| 1 | +//// [tests/cases/compiler/typeParameterConstrainedToArrayIndexableByNumericStringType.ts] //// |
| 2 | + |
| 3 | +=== typeParameterConstrainedToArrayIndexableByNumericStringType.ts === |
| 4 | +// https://github.com/microsoft/TypeScript/issues/56823 |
| 5 | + |
| 6 | +declare function test1<A extends unknown[]>(arr: A): A[`${number}`]; |
| 7 | +>test1 : Symbol(test1, Decl(typeParameterConstrainedToArrayIndexableByNumericStringType.ts, 0, 0)) |
| 8 | +>A : Symbol(A, Decl(typeParameterConstrainedToArrayIndexableByNumericStringType.ts, 2, 23)) |
| 9 | +>arr : Symbol(arr, Decl(typeParameterConstrainedToArrayIndexableByNumericStringType.ts, 2, 44)) |
| 10 | +>A : Symbol(A, Decl(typeParameterConstrainedToArrayIndexableByNumericStringType.ts, 2, 23)) |
| 11 | +>A : Symbol(A, Decl(typeParameterConstrainedToArrayIndexableByNumericStringType.ts, 2, 23)) |
| 12 | + |
| 13 | +const res1 = test1([1, 2, 3]); |
| 14 | +>res1 : Symbol(res1, Decl(typeParameterConstrainedToArrayIndexableByNumericStringType.ts, 3, 5)) |
| 15 | +>test1 : Symbol(test1, Decl(typeParameterConstrainedToArrayIndexableByNumericStringType.ts, 0, 0)) |
| 16 | + |
| 17 | +declare function test2<A extends [unknown, unknown]>(arr: A): A[`${number}`]; |
| 18 | +>test2 : Symbol(test2, Decl(typeParameterConstrainedToArrayIndexableByNumericStringType.ts, 3, 30)) |
| 19 | +>A : Symbol(A, Decl(typeParameterConstrainedToArrayIndexableByNumericStringType.ts, 5, 23)) |
| 20 | +>arr : Symbol(arr, Decl(typeParameterConstrainedToArrayIndexableByNumericStringType.ts, 5, 53)) |
| 21 | +>A : Symbol(A, Decl(typeParameterConstrainedToArrayIndexableByNumericStringType.ts, 5, 23)) |
| 22 | +>A : Symbol(A, Decl(typeParameterConstrainedToArrayIndexableByNumericStringType.ts, 5, 23)) |
| 23 | + |
| 24 | +const res2 = test2([1, 'foo']); |
| 25 | +>res2 : Symbol(res2, Decl(typeParameterConstrainedToArrayIndexableByNumericStringType.ts, 6, 5)) |
| 26 | +>test2 : Symbol(test2, Decl(typeParameterConstrainedToArrayIndexableByNumericStringType.ts, 3, 30)) |
| 27 | + |
| 28 | +declare function test3<A extends [unknown, unknown, ...unknown[]]>(arr: A): A[`${number}`]; |
| 29 | +>test3 : Symbol(test3, Decl(typeParameterConstrainedToArrayIndexableByNumericStringType.ts, 6, 31)) |
| 30 | +>A : Symbol(A, Decl(typeParameterConstrainedToArrayIndexableByNumericStringType.ts, 8, 23)) |
| 31 | +>arr : Symbol(arr, Decl(typeParameterConstrainedToArrayIndexableByNumericStringType.ts, 8, 67)) |
| 32 | +>A : Symbol(A, Decl(typeParameterConstrainedToArrayIndexableByNumericStringType.ts, 8, 23)) |
| 33 | +>A : Symbol(A, Decl(typeParameterConstrainedToArrayIndexableByNumericStringType.ts, 8, 23)) |
| 34 | + |
| 35 | +const res3 = test3([1, 'foo', true]); |
| 36 | +>res3 : Symbol(res3, Decl(typeParameterConstrainedToArrayIndexableByNumericStringType.ts, 9, 5)) |
| 37 | +>test3 : Symbol(test3, Decl(typeParameterConstrainedToArrayIndexableByNumericStringType.ts, 6, 31)) |
| 38 | + |
| 39 | +declare const tuple1: [number, string, ...boolean[]]; |
| 40 | +>tuple1 : Symbol(tuple1, Decl(typeParameterConstrainedToArrayIndexableByNumericStringType.ts, 10, 13)) |
| 41 | + |
| 42 | +const res4 = test3(tuple1); |
| 43 | +>res4 : Symbol(res4, Decl(typeParameterConstrainedToArrayIndexableByNumericStringType.ts, 11, 5)) |
| 44 | +>test3 : Symbol(test3, Decl(typeParameterConstrainedToArrayIndexableByNumericStringType.ts, 6, 31)) |
| 45 | +>tuple1 : Symbol(tuple1, Decl(typeParameterConstrainedToArrayIndexableByNumericStringType.ts, 10, 13)) |
| 46 | + |
0 commit comments