File: readonlyRestParameters.errors.txt

package info (click to toggle)
node-typescript 4.9.5%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 533,908 kB
  • sloc: javascript: 2,018,330; makefile: 7; sh: 1
file content (39 lines) | stat: -rw-r--r-- 1,482 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
tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts(8,8): error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter.
tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts(20,15): error TS2554: Expected 2 arguments, but got 3.
tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts(25,5): error TS2542: Index signature in type 'readonly string[]' only permits reading.


==== tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts (3 errors) ====
    function f0(a: string, b: string) {
        f0(a, b);
        f1(a, b);
        f2(a, b);
    }
    
    function f1(...args: readonly string[]) {
        f0(...args);  // Error
           ~~~~~~~
!!! error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter.
        f1('abc', 'def');
        f1('abc', ...args);
        f1(...args);
    }
    
    function f2(...args: readonly [string, string]) {
        f0(...args);
        f1('abc', 'def');
        f1('abc', ...args);
        f1(...args);
        f2('abc', 'def');
        f2('abc', ...args);  // Error
                  ~~~~~~~
!!! error TS2554: Expected 2 arguments, but got 3.
        f2(...args);
    }
    
    function f4(...args: readonly string[]) {
        args[0] = 'abc';  // Error
        ~~~~~~~
!!! error TS2542: Index signature in type 'readonly string[]' only permits reading.
    }