File: arraySpreadInCall.errors.txt

package info (click to toggle)
node-typescript 5.1.6%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 492,516 kB
  • sloc: javascript: 2,078,951; makefile: 6; sh: 1
file content (29 lines) | stat: -rw-r--r-- 1,069 bytes parent folder | download
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
tests/cases/conformance/es6/spread/arraySpreadInCall.ts(21,12): error TS2554: Expected 0-1 arguments, but got 2.


==== tests/cases/conformance/es6/spread/arraySpreadInCall.ts (1 errors) ====
    declare function f1(a: number, b: number, c: number, d: number, e: number, f: number): void;
    f1(1, 2, 3, 4, ...[5, 6]);
    f1(...[1], 2, 3, 4, 5, 6);
    f1(1, 2, ...[3, 4], 5, 6);
    f1(1, 2, ...[3], 4, ...[5, 6]);
    f1(...[1, 2], ...[3, 4], ...[5, 6]);
    
    declare function f2<T extends unknown[]>(...args: T): T;
    const x21 = f2(...[1, 'foo'])
    const x22 = f2(true, ...[1, 'foo'])
    
    declare function f3<T extends readonly unknown[]>(...args: T): T;
    const x31 = f3(...[1, 'foo'])
    const x32 = f3(true, ...[1, 'foo'])
    
    // dicovered in #52845#issuecomment-1459132562
    interface IAction {
        run(event?: unknown): unknown;
    }
    declare const action: IAction
    action.run(...[100, 'foo']) // error
               ~~~~~~~~~~~~~~~
!!! error TS2554: Expected 0-1 arguments, but got 2.