File: variadicTuples1.errors.txt

package info (click to toggle)
node-typescript 5.0.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 459,140 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (508 lines) | stat: -rw-r--r-- 23,969 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
tests/cases/conformance/types/tuple/variadicTuples1.ts(52,5): error TS2555: Expected at least 3 arguments, but got 2.
tests/cases/conformance/types/tuple/variadicTuples1.ts(53,17): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
tests/cases/conformance/types/tuple/variadicTuples1.ts(62,5): error TS2345: Argument of type '[]' is not assignable to parameter of type '[...unknown[], number]'.
  Source has 0 element(s) but target requires 1.
tests/cases/conformance/types/tuple/variadicTuples1.ts(131,9): error TS2344: Type 'V' does not satisfy the constraint 'unknown[]'.
  The type 'readonly unknown[]' is 'readonly' and cannot be assigned to the mutable type 'unknown[]'.
tests/cases/conformance/types/tuple/variadicTuples1.ts(149,5): error TS2322: Type '[string, ...unknown[]]' is not assignable to type '[string, ...T]'.
  Target requires 2 element(s) but source may have fewer.
tests/cases/conformance/types/tuple/variadicTuples1.ts(151,5): error TS2322: Type '[string, ...unknown[]]' is not assignable to type '[string, ...U]'.
  Target requires 2 element(s) but source may have fewer.
tests/cases/conformance/types/tuple/variadicTuples1.ts(152,5): error TS2322: Type '[string, ...T]' is not assignable to type '[string, ...U]'.
  Type at position 1 in source is not compatible with type at position 1 in target.
    Type 'T' is not assignable to type 'U'.
      'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'string[]'.
tests/cases/conformance/types/tuple/variadicTuples1.ts(160,5): error TS2322: Type 'readonly [...T]' is not assignable to type 'T'.
  'T' could be instantiated with an arbitrary type which could be unrelated to 'readonly [...T]'.
tests/cases/conformance/types/tuple/variadicTuples1.ts(162,5): error TS4104: The type 'readonly [...T]' is 'readonly' and cannot be assigned to the mutable type '[...T]'.
tests/cases/conformance/types/tuple/variadicTuples1.ts(169,5): error TS2322: Type 'readonly [...T]' is not assignable to type 'T'.
  'readonly [...T]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'readonly unknown[]'.
tests/cases/conformance/types/tuple/variadicTuples1.ts(170,5): error TS2322: Type 'T' is not assignable to type '[...T]'.
  The type 'readonly unknown[]' is 'readonly' and cannot be assigned to the mutable type '[...T]'.
tests/cases/conformance/types/tuple/variadicTuples1.ts(171,5): error TS4104: The type 'readonly [...T]' is 'readonly' and cannot be assigned to the mutable type '[...T]'.
tests/cases/conformance/types/tuple/variadicTuples1.ts(181,5): error TS2322: Type 'T' is not assignable to type '[...U]'.
  Type 'string[]' is not assignable to type '[...U]'.
    Target requires 1 element(s) but source may have fewer.
tests/cases/conformance/types/tuple/variadicTuples1.ts(182,5): error TS2322: Type '[...T]' is not assignable to type '[...U]'.
  Type 'T' is not assignable to type 'U'.
    'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'string[]'.
tests/cases/conformance/types/tuple/variadicTuples1.ts(188,5): error TS2322: Type 'T' is not assignable to type '[...T]'.
  The type 'readonly string[]' is 'readonly' and cannot be assigned to the mutable type '[...T]'.
tests/cases/conformance/types/tuple/variadicTuples1.ts(190,5): error TS2322: Type 'T' is not assignable to type '[...U]'.
  The type 'readonly string[]' is 'readonly' and cannot be assigned to the mutable type '[...U]'.
tests/cases/conformance/types/tuple/variadicTuples1.ts(191,5): error TS2322: Type '[...T]' is not assignable to type '[...U]'.
  Type 'T' is not assignable to type 'U'.
    'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'readonly string[]'.
tests/cases/conformance/types/tuple/variadicTuples1.ts(203,5): error TS2322: Type 'string' is not assignable to type 'keyof [1, 2, ...T]'.
  Type '"2"' is not assignable to type '"0" | "1" | keyof T[]'.
tests/cases/conformance/types/tuple/variadicTuples1.ts(357,26): error TS2322: Type 'string' is not assignable to type 'number'.
tests/cases/conformance/types/tuple/variadicTuples1.ts(397,7): error TS2322: Type '[false, false]' is not assignable to type '[...number[], boolean]'.
  Type at position 0 in source is not compatible with type at position 0 in target.
    Type 'boolean' is not assignable to type 'number'.


==== tests/cases/conformance/types/tuple/variadicTuples1.ts (20 errors) ====
    // Variadics in tuple types
    
    type TV0<T extends unknown[]> = [string, ...T];
    type TV1<T extends unknown[]> = [string, ...T, number];
    type TV2<T extends unknown[]> = [string, ...T, number, ...T];
    type TV3<T extends unknown[]> = [string, ...T, ...number[], ...T];
    
    // Normalization
    
    type TN1 = TV1<[boolean, string]>;
    type TN2 = TV1<[]>;
    type TN3 = TV1<[boolean?]>;
    type TN4 = TV1<string[]>;
    type TN5 = TV1<[boolean] | [symbol, symbol]>;
    type TN6 = TV1<any>;
    type TN7 = TV1<never>;
    
    // Variadics in array literals
    
    function tup2<T extends unknown[], U extends unknown[]>(t: [...T], u: [...U]) {
        return [1, ...t, 2, ...u, 3] as const;
    }
    
    const t2 = tup2(['hello'], [10, true]);
    
    function concat<T extends unknown[], U extends unknown[]>(t: [...T], u: [...U]): [...T, ...U] {
        return [...t, ...u];
    }
    
    declare const sa: string[];
    
    const tc1 = concat([], []);
    const tc2 = concat(['hello'], [42]);
    const tc3 = concat([1, 2, 3], sa);
    const tc4 = concat(sa, [1, 2, 3]);  // Ideally would be [...string[], number, number, number]
    
    function concat2<T extends readonly unknown[], U extends readonly unknown[]>(t: T, u: U) {
        return [...t, ...u];  // (T[number] | U[number])[]
    }
    
    const tc5 = concat2([1, 2, 3] as const, [4, 5, 6] as const);  // (1 | 2 | 3 | 4 | 5 | 6)[]
    
    // Spread arguments
    
    declare function foo1(a: number, b: string, c: boolean, ...d: number[]): void;
    
    function foo2(t1: [number, string], t2: [boolean], a1: number[]) {
        foo1(1, 'abc', true, 42, 43, 44);
        foo1(...t1, true, 42, 43, 44);
        foo1(...t1, ...t2, 42, 43, 44);
        foo1(...t1, ...t2, ...a1);
        foo1(...t1);  // Error
        ~~~~~~~~~~~
!!! error TS2555: Expected at least 3 arguments, but got 2.
!!! related TS6210 tests/cases/conformance/types/tuple/variadicTuples1.ts:45:45: An argument for 'c' was not provided.
        foo1(...t1, 45);  // Error
                    ~~
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
    }
    
    declare function foo3<T extends unknown[]>(x: number, ...args: [...T, number]): T;
    
    function foo4<U extends unknown[]>(u: U) {
        foo3(1, 2);
        foo3(1, 'hello', true, 2);
        foo3(1, ...u, 'hi', 2);
        foo3(1);
        ~~~~~~~
!!! error TS2345: Argument of type '[]' is not assignable to parameter of type '[...unknown[], number]'.
!!! error TS2345:   Source has 0 element(s) but target requires 1.
    }
    
    // Contextual typing of array literals
    
    declare function ft1<T extends unknown[]>(t: T): T;
    declare function ft2<T extends unknown[]>(t: T): readonly [...T];
    declare function ft3<T extends unknown[]>(t: [...T]): T;
    declare function ft4<T extends unknown[]>(t: [...T]): readonly [...T];
    
    ft1(['hello', 42]);  // (string | number)[]
    ft2(['hello', 42]);  // readonly (string | number)[]
    ft3(['hello', 42]);  // [string, number]
    ft4(['hello', 42]);  // readonly [string, number]
    
    // Indexing variadic tuple types
    
    function f0<T extends unknown[]>(t: [string, ...T], n: number) {
        const a = t[0];  // string
        const b = t[1];  // [string, ...T][1]
        const c = t[2];  // [string, ...T][2]
        const d = t[n];  // [string, ...T][number]
    }
    
    function f1<T extends unknown[]>(t: [string, ...T, number], n: number) {
        const a = t[0];  // string
        const b = t[1];  // [string, ...T, number][1]
        const c = t[2];  // [string, ...T, number][2]
        const d = t[n];  // [string, ...T, number][number]
    }
    
    // Destructuring variadic tuple types
    
    function f2<T extends unknown[]>(t: [string, ...T]) {
        let [...ax] = t;  // [string, ...T]
        let [b1, ...bx] = t;  // string, [...T]
        let [c1, c2, ...cx] = t;  // string, [string, ...T][1], T[number][]
    }
    
    function f3<T extends unknown[]>(t: [string, ...T, number]) {
        let [...ax] = t;  // [string, ...T, number]
        let [b1, ...bx] = t;  // string, [...T, number]
        let [c1, c2, ...cx] = t;  // string, [string, ...T, number][1], (number | T[number])[]
    }
    
    // Mapped types applied to variadic tuple types
    
    type Arrayify<T> = { [P in keyof T]: T[P][] };
    
    type TM1<U extends unknown[]> = Arrayify<readonly [string, number?, ...U, ...boolean[]]>;  // [string[], (number | undefined)[]?, Arrayify<U>, ...boolean[][]]
    
    type TP1<T extends unknown[]> = Partial<[string, ...T, number]>;  // [string?, Partial<T>, number?]
    type TP2<T extends unknown[]> = Partial<[string, ...T, ...number[]]>;  // [string?, Partial<T>, ...(number | undefined)[]]
    
    // Reverse mapping through mapped type applied to variadic tuple type
    
    declare function fm1<T extends unknown[]>(t: Arrayify<[string, number, ...T]>): T;
    
    let tm1 = fm1([['abc'], [42], [true], ['def']]);  // [boolean, string]
    
    // Spread of readonly array-like infers mutable array-like
    
    declare function fx1<T extends unknown[]>(a: string, ...args: T): T;
    
    function gx1<U extends unknown[], V extends readonly unknown[]>(u: U, v: V) {
        fx1('abc');  // []
        fx1('abc', ...u);  // U
        fx1('abc', ...v);  // [...V]
        fx1<U>('abc', ...u);  // U
        fx1<V>('abc', ...v);  // Error
            ~
!!! error TS2344: Type 'V' does not satisfy the constraint 'unknown[]'.
!!! error TS2344:   The type 'readonly unknown[]' is 'readonly' and cannot be assigned to the mutable type 'unknown[]'.
    }
    
    declare function fx2<T extends readonly unknown[]>(a: string, ...args: T): T;
    
    function gx2<U extends unknown[], V extends readonly unknown[]>(u: U, v: V) {
        fx2('abc');  // []
        fx2('abc', ...u);  // U
        fx2('abc', ...v);  // [...V]
        fx2<U>('abc', ...u);  // U
        fx2<V>('abc', ...v);  // V
    }
    
    // Relations involving variadic tuple types
    
    function f10<T extends string[], U extends T>(x: [string, ...unknown[]], y: [string, ...T], z: [string, ...U]) {
        x = y;
        x = z;
        y = x;  // Error
        ~
!!! error TS2322: Type '[string, ...unknown[]]' is not assignable to type '[string, ...T]'.
!!! error TS2322:   Target requires 2 element(s) but source may have fewer.
        y = z;
        z = x;  // Error
        ~
!!! error TS2322: Type '[string, ...unknown[]]' is not assignable to type '[string, ...U]'.
!!! error TS2322:   Target requires 2 element(s) but source may have fewer.
        z = y;  // Error
        ~
!!! error TS2322: Type '[string, ...T]' is not assignable to type '[string, ...U]'.
!!! error TS2322:   Type at position 1 in source is not compatible with type at position 1 in target.
!!! error TS2322:     Type 'T' is not assignable to type 'U'.
!!! error TS2322:       'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'string[]'.
    }
    
    // For a generic type T, [...T] is assignable to T, T is assignable to readonly [...T], and T is assignable
    // to [...T] when T is constrained to a mutable array or tuple type.
    
    function f11<T extends unknown[]>(t: T, m: [...T], r: readonly [...T]) {
        t = m;
        t = r;  // Error
        ~
!!! error TS2322: Type 'readonly [...T]' is not assignable to type 'T'.
!!! error TS2322:   'T' could be instantiated with an arbitrary type which could be unrelated to 'readonly [...T]'.
        m = t;
        m = r;  // Error
        ~
!!! error TS4104: The type 'readonly [...T]' is 'readonly' and cannot be assigned to the mutable type '[...T]'.
        r = t;
        r = m;
    }
    
    function f12<T extends readonly unknown[]>(t: T, m: [...T], r: readonly [...T]) {
        t = m;
        t = r;  // Error
        ~
!!! error TS2322: Type 'readonly [...T]' is not assignable to type 'T'.
!!! error TS2322:   'readonly [...T]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'readonly unknown[]'.
        m = t;  // Error
        ~
!!! error TS2322: Type 'T' is not assignable to type '[...T]'.
!!! error TS2322:   The type 'readonly unknown[]' is 'readonly' and cannot be assigned to the mutable type '[...T]'.
        m = r;  // Error
        ~
!!! error TS4104: The type 'readonly [...T]' is 'readonly' and cannot be assigned to the mutable type '[...T]'.
        r = t;
        r = m;
    }
    
    function f13<T extends string[], U extends T>(t0: T, t1: [...T], t2: [...U]) {
        t0 = t1;
        t0 = t2;
        t1 = t0;
        t1 = t2;
        t2 = t0;  // Error
        ~~
!!! error TS2322: Type 'T' is not assignable to type '[...U]'.
!!! error TS2322:   Type 'string[]' is not assignable to type '[...U]'.
!!! error TS2322:     Target requires 1 element(s) but source may have fewer.
        t2 = t1;  // Error
        ~~
!!! error TS2322: Type '[...T]' is not assignable to type '[...U]'.
!!! error TS2322:   Type 'T' is not assignable to type 'U'.
!!! error TS2322:     'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'string[]'.
    }
    
    function f14<T extends readonly string[], U extends T>(t0: T, t1: [...T], t2: [...U]) {
        t0 = t1;
        t0 = t2;
        t1 = t0;  // Error
        ~~
!!! error TS2322: Type 'T' is not assignable to type '[...T]'.
!!! error TS2322:   The type 'readonly string[]' is 'readonly' and cannot be assigned to the mutable type '[...T]'.
        t1 = t2;
        t2 = t0;  // Error
        ~~
!!! error TS2322: Type 'T' is not assignable to type '[...U]'.
!!! error TS2322:   The type 'readonly string[]' is 'readonly' and cannot be assigned to the mutable type '[...U]'.
        t2 = t1;  // Error
        ~~
!!! error TS2322: Type '[...T]' is not assignable to type '[...U]'.
!!! error TS2322:   Type 'T' is not assignable to type 'U'.
!!! error TS2322:     'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'readonly string[]'.
    }
    
    function f15<T extends string[], U extends T>(k0: keyof T, k1: keyof [...T], k2: keyof [...U], k3: keyof [1, 2, ...T]) {
        k0 = 'length';
        k1 = 'length';
        k2 = 'length';
        k0 = 'slice';
        k1 = 'slice';
        k2 = 'slice';
        k3 = '0';
        k3 = '1';
        k3 = '2';  // Error
        ~~
!!! error TS2322: Type 'string' is not assignable to type 'keyof [1, 2, ...T]'.
!!! error TS2322:   Type '"2"' is not assignable to type '"0" | "1" | keyof T[]'.
    }
    
    // Inference between variadic tuple types
    
    type First<T extends readonly unknown[]> =
        T extends readonly [unknown, ...unknown[]] ? T[0] :
        T[0] | undefined;
    
    type DropFirst<T extends readonly unknown[]> = T extends readonly [unknown?, ...infer U] ? U : [...T];
    
    type Last<T extends readonly unknown[]> =
        T extends readonly [...unknown[], infer U] ? U :
        T extends readonly [unknown, ...unknown[]] ? T[number] :
        T[number] | undefined;
    
    type DropLast<T extends readonly unknown[]> = T extends readonly [...infer U, unknown] ? U : [...T];
    
    type T00 = First<[number, symbol, string]>;
    type T01 = First<[symbol, string]>;
    type T02 = First<[string]>;
    type T03 = First<[number, symbol, ...string[]]>;
    type T04 = First<[symbol, ...string[]]>;
    type T05 = First<[string?]>;
    type T06 = First<string[]>;
    type T07 = First<[]>;
    type T08 = First<any>;
    type T09 = First<never>;
    
    type T10 = DropFirst<[number, symbol, string]>;
    type T11 = DropFirst<[symbol, string]>;
    type T12 = DropFirst<[string]>;
    type T13 = DropFirst<[number, symbol, ...string[]]>;
    type T14 = DropFirst<[symbol, ...string[]]>;
    type T15 = DropFirst<[string?]>;
    type T16 = DropFirst<string[]>;
    type T17 = DropFirst<[]>;
    type T18 = DropFirst<any>;
    type T19 = DropFirst<never>;
    
    type T20 = Last<[number, symbol, string]>;
    type T21 = Last<[symbol, string]>;
    type T22 = Last<[string]>;
    type T23 = Last<[number, symbol, ...string[]]>;
    type T24 = Last<[symbol, ...string[]]>;
    type T25 = Last<[string?]>;
    type T26 = Last<string[]>;
    type T27 = Last<[]>;
    type T28 = Last<any>;
    type T29 = Last<never>;
    
    type T30 = DropLast<[number, symbol, string]>;
    type T31 = DropLast<[symbol, string]>;
    type T32 = DropLast<[string]>;
    type T33 = DropLast<[number, symbol, ...string[]]>;
    type T34 = DropLast<[symbol, ...string[]]>;
    type T35 = DropLast<[string?]>;
    type T36 = DropLast<string[]>;
    type T37 = DropLast<[]>;  // unknown[], maybe should be []
    type T38 = DropLast<any>;
    type T39 = DropLast<never>;
    
    type R00 = First<readonly [number, symbol, string]>;
    type R01 = First<readonly [symbol, string]>;
    type R02 = First<readonly [string]>;
    type R03 = First<readonly [number, symbol, ...string[]]>;
    type R04 = First<readonly [symbol, ...string[]]>;
    type R05 = First<readonly string[]>;
    type R06 = First<readonly []>;
    
    type R10 = DropFirst<readonly [number, symbol, string]>;
    type R11 = DropFirst<readonly [symbol, string]>;
    type R12 = DropFirst<readonly [string]>;
    type R13 = DropFirst<readonly [number, symbol, ...string[]]>;
    type R14 = DropFirst<readonly [symbol, ...string[]]>;
    type R15 = DropFirst<readonly string[]>;
    type R16 = DropFirst<readonly []>;
    
    type R20 = Last<readonly [number, symbol, string]>;
    type R21 = Last<readonly [symbol, string]>;
    type R22 = Last<readonly [string]>;
    type R23 = Last<readonly [number, symbol, ...string[]]>;
    type R24 = Last<readonly [symbol, ...string[]]>;
    type R25 = Last<readonly string[]>;
    type R26 = Last<readonly []>;
    
    type R30 = DropLast<readonly [number, symbol, string]>;
    type R31 = DropLast<readonly [symbol, string]>;
    type R32 = DropLast<readonly [string]>;
    type R33 = DropLast<readonly [number, symbol, ...string[]]>;
    type R34 = DropLast<readonly [symbol, ...string[]]>;
    type R35 = DropLast<readonly string[]>;
    type R36 = DropLast<readonly []>;
    
    // Inference to [...T, ...U] with implied arity for T
    
    function curry<T extends unknown[], U extends unknown[], R>(f: (...args: [...T, ...U]) => R, ...a: T) {
        return (...b: U) => f(...a, ...b);
    }
    
    const fn1 = (a: number, b: string, c: boolean, d: string[]) => 0;
    
    const c0 = curry(fn1);  // (a: number, b: string, c: boolean, d: string[]) => number
    const c1 = curry(fn1, 1);  // (b: string, c: boolean, d: string[]) => number
    const c2 = curry(fn1, 1, 'abc');  // (c: boolean, d: string[]) => number
    const c3 = curry(fn1, 1, 'abc', true);  // (d: string[]) => number
    const c4 = curry(fn1, 1, 'abc', true, ['x', 'y']);  // () => number
    
    const fn2 = (x: number, b: boolean, ...args: string[]) => 0;
    
    const c10 = curry(fn2);  // (x: number, b: boolean, ...args: string[]) => number
    const c11 = curry(fn2, 1);  // (b: boolean, ...args: string[]) => number
    const c12 = curry(fn2, 1, true);  // (...args: string[]) => number
    const c13 = curry(fn2, 1, true, 'abc', 'def');  // (...args: string[]) => number
    
    const fn3 = (...args: string[]) => 0;
    
    const c20 = curry(fn3);  // (...args: string[]) => number
    const c21 = curry(fn3, 'abc', 'def');  // (...args: string[]) => number
    const c22 = curry(fn3, ...sa);  // (...args: string[]) => number
    
    // No inference to [...T, ...U] when there is no implied arity
    
    function curry2<T extends unknown[], U extends unknown[], R>(f: (...args: [...T, ...U]) => R, t: [...T], u: [...U]) {
        return f(...t, ...u);
    }
    
    declare function fn10(a: string, b: number, c: boolean): string[];
    
    curry2(fn10, ['hello', 42], [true]);
    curry2(fn10, ['hello'], [42, true]);
    
    // Inference to [...T] has higher priority than inference to [...T, number?]
    
    declare function ft<T extends unknown[]>(t1: [...T], t2: [...T, number?]): T;
    
    ft([1, 2, 3], [1, 2, 3]);
    ft([1, 2], [1, 2, 3]);
    ft(['a', 'b'], ['c', 'd'])
    ft(['a', 'b'], ['c', 'd', 42])
    
    // Last argument is contextually typed
    
    declare function call<T extends unknown[], R>(...args: [...T, (...args: T) => R]): [T, R];
    
    call('hello', 32, (a, b) => 42);
    call(...sa, (...x) => 42);
    
    // No inference to ending optional elements (except with identical structure)
    
    declare function f20<T extends unknown[] = []>(args: [...T, number?]): T;
    
    function f21<U extends string[]>(args: [...U, number?]) {
        let v1 = f20(args);  // U
        let v2 = f20(["foo", "bar"]);  // [string]
                             ~~~~~
!!! error TS2322: Type 'string' is not assignable to type 'number'.
        let v3 = f20(["foo", 42]);  // [string]
    }
    
    declare function f22<T extends unknown[] = []>(args: [...T, number]): T;
    declare function f22<T extends unknown[] = []>(args: [...T]): T;
    
    function f23<U extends string[]>(args: [...U, number]) {
        let v1 = f22(args);  // U
        let v2 = f22(["foo", "bar"]);  // [string, string]
        let v3 = f22(["foo", 42]);  // [string]
    }
    
    // Repro from #39327
    
    interface Desc<A extends unknown[], T> {
        readonly f: (...args: A) => T;
        bind<T extends unknown[], U extends unknown[], R>(this: Desc<[...T, ...U], R>, ...args: T): Desc<[...U], R>;
    }
    
    declare const a: Desc<[string, number, boolean], object>;
    const b = a.bind("", 1);  // Desc<[boolean], object>
    
    // Repro from #39607
    
    declare function getUser(id: string, options?: { x?: string }): string;
    
    declare function getOrgUser(id: string, orgId: number, options?: { y?: number, z?: boolean }): void;
    
    function callApi<T extends unknown[] = [], U = void>(method: (...args: [...T, object]) => U) {
        return (...args: [...T]) => method(...args, {});
    }
    
    callApi(getUser);
    callApi(getOrgUser);
    
    // Repro from #40235
    
    type Numbers = number[];
    type Unbounded = [...Numbers, boolean];
    const data: Unbounded = [false, false];  // Error
          ~~~~
!!! error TS2322: Type '[false, false]' is not assignable to type '[...number[], boolean]'.
!!! error TS2322:   Type at position 0 in source is not compatible with type at position 0 in target.
!!! error TS2322:     Type 'boolean' is not assignable to type 'number'.
    
    type U1 = [string, ...Numbers, boolean];
    type U2 = [...[string, ...Numbers], boolean];
    type U3 = [...[string, number], boolean];