|
| 1 | +tests/cases/conformance/types/tuple/indexerWithTuple.ts(11,25): error TS2733: Index '2' is out-of-bounds in tuple of length 1. |
| 2 | +tests/cases/conformance/types/tuple/indexerWithTuple.ts(17,27): error TS2733: Index '2' is out-of-bounds in tuple of length 1. |
| 3 | +tests/cases/conformance/types/tuple/indexerWithTuple.ts(20,30): error TS2733: Index '2' is out-of-bounds in tuple of length 1. |
| 4 | +tests/cases/conformance/types/tuple/indexerWithTuple.ts(28,30): error TS2733: Index '2' is out-of-bounds in tuple of length 1. |
| 5 | + |
| 6 | + |
| 7 | +==== tests/cases/conformance/types/tuple/indexerWithTuple.ts (4 errors) ==== |
| 8 | + var strNumTuple: [string, number] = ["foo", 10]; |
| 9 | + var numTupleTuple: [number, [string, number]] = [10, ["bar", 20]]; |
| 10 | + var unionTuple1: [number, string| number] = [10, "foo"]; |
| 11 | + var unionTuple2: [boolean, string| number] = [true, "foo"]; |
| 12 | + |
| 13 | + // no error |
| 14 | + var idx0 = 0; |
| 15 | + var idx1 = 1; |
| 16 | + var ele10 = strNumTuple[0]; // string |
| 17 | + var ele11 = strNumTuple[1]; // number |
| 18 | + var ele12 = strNumTuple[2]; // string | number |
| 19 | + ~ |
| 20 | +!!! error TS2733: Index '2' is out-of-bounds in tuple of length 1. |
| 21 | + var ele13 = strNumTuple[idx0]; // string | number |
| 22 | + var ele14 = strNumTuple[idx1]; // string | number |
| 23 | + var ele15 = strNumTuple["0"]; // string |
| 24 | + var ele16 = strNumTuple["1"]; // number |
| 25 | + var strNumTuple1 = numTupleTuple[1]; //[string, number]; |
| 26 | + var ele17 = numTupleTuple[2]; // number | [string, number] |
| 27 | + ~ |
| 28 | +!!! error TS2733: Index '2' is out-of-bounds in tuple of length 1. |
| 29 | + var eleUnion10 = unionTuple1[0]; // number |
| 30 | + var eleUnion11 = unionTuple1[1]; // string | number |
| 31 | + var eleUnion12 = unionTuple1[2]; // string | number |
| 32 | + ~ |
| 33 | +!!! error TS2733: Index '2' is out-of-bounds in tuple of length 1. |
| 34 | + var eleUnion13 = unionTuple1[idx0]; // string | number |
| 35 | + var eleUnion14 = unionTuple1[idx1]; // string | number |
| 36 | + var eleUnion15 = unionTuple1["0"]; // number |
| 37 | + var eleUnion16 = unionTuple1["1"]; // string | number |
| 38 | + |
| 39 | + var eleUnion20 = unionTuple2[0]; // boolean |
| 40 | + var eleUnion21 = unionTuple2[1]; // string | number |
| 41 | + var eleUnion22 = unionTuple2[2]; // string | number | boolean |
| 42 | + ~ |
| 43 | +!!! error TS2733: Index '2' is out-of-bounds in tuple of length 1. |
| 44 | + var eleUnion23 = unionTuple2[idx0]; // string | number | boolean |
| 45 | + var eleUnion24 = unionTuple2[idx1]; // string | number | boolean |
| 46 | + var eleUnion25 = unionTuple2["0"]; // boolean |
| 47 | + var eleUnion26 = unionTuple2["1"]; // string | number |
0 commit comments