Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2f34990

Browse files
committed
add another test for spread elements in tuple types
1 parent ea583fe commit 2f34990

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

javascript/ql/test/library-tests/TypeScript/TypeAnnotations/tests.expected

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ test_VariableTypes
112112
| tst.ts:164:47:164:50 | arr1 | arr1 | tst.ts:164:53:164:53 | T |
113113
| tst.ts:164:56:164:59 | arr2 | arr2 | tst.ts:164:62:164:62 | U |
114114
| tst.ts:169:31:169:31 | x | x | tst.ts:169:34:169:64 | [first: ... number] |
115+
| tst.ts:180:5:180:7 | foo | foo | tst.ts:180:10:180:21 | StrStrNumNum |
115116
test_QualifiedTypeAccess
116117
| tst.ts:63:19:63:21 | N.I | tst.ts:63:19:63:19 | N | tst.ts:63:21:63:21 | I |
117118
| tst.ts:64:20:64:24 | N.M.I | tst.ts:64:20:64:22 | N.M | tst.ts:64:24:64:24 | I |
@@ -208,6 +209,12 @@ test_TupleTypeExpr
208209
| tst.ts:164:66:164:77 | [...T, ...U] | 1 | 2 | tst.ts:164:73:164:76 | ...U |
209210
| tst.ts:169:34:169:64 | [first: ... number] | 0 | 2 | tst.ts:169:42:169:47 | number |
210211
| tst.ts:169:34:169:64 | [first: ... number] | 1 | 2 | tst.ts:169:58:169:63 | number |
212+
| tst.ts:175:16:175:31 | [string, string] | 0 | 2 | tst.ts:175:17:175:22 | string |
213+
| tst.ts:175:16:175:31 | [string, string] | 1 | 2 | tst.ts:175:25:175:30 | string |
214+
| tst.ts:176:16:176:31 | [number, number] | 0 | 2 | tst.ts:176:17:176:22 | number |
215+
| tst.ts:176:16:176:31 | [number, number] | 1 | 2 | tst.ts:176:25:176:30 | number |
216+
| tst.ts:179:21:179:44 | [...Str ... umbers] | 0 | 2 | tst.ts:179:22:179:31 | ...Strings |
217+
| tst.ts:179:21:179:44 | [...Str ... umbers] | 1 | 2 | tst.ts:179:34:179:43 | ...Numbers |
211218
test_FieldTypes
212219
| tst.ts:15:3:15:22 | numberField: number; | tst.ts:15:16:15:21 | number |
213220
| tst.ts:16:3:16:22 | stringField: string; | tst.ts:16:16:16:21 | string |

javascript/ql/test/library-tests/TypeScript/TypeAnnotations/tst.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,12 @@ function concat<T extends Arr, U extends Arr>(arr1: T, arr2: U): [...T, ...U] {
169169
function labelOnTupleElements(x: [first: number, second: number]): number {
170170
let [a, b] = x;
171171
return a + b;
172-
}
172+
}
173+
174+
// spread elements can occur anywhere in a tuple – not just at the end!
175+
type Strings = [string, string];
176+
type Numbers = [number, number];
177+
178+
// [string, string, number, number]
179+
type StrStrNumNum = [...Strings, ...Numbers];
180+
var foo: StrStrNumNum;

0 commit comments

Comments
 (0)