File: destructuringParameterDeclaration4.errors.txt

package info (click to toggle)
node-typescript 2.1.5-1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 203,960 kB
  • sloc: sh: 11; makefile: 5
file content (86 lines) | stat: -rw-r--r-- 5,514 bytes parent folder | download | duplicates (2)
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
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(11,13): error TS2370: A rest parameter must be of an array type.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(13,13): error TS2370: A rest parameter must be of an array type.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(14,17): error TS1047: A rest parameter cannot be optional.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(15,16): error TS1048: A rest parameter cannot have an initializer.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(20,19): error TS2345: Argument of type 'true' is not assignable to parameter of type 'string | number'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(21,7): error TS2304: Cannot find name 'array2'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(22,4): error TS2345: Argument of type '[number, number, string, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'.
  Types of property '2' are incompatible.
    Type 'string' is not assignable to type '[[any]]'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(23,4): error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]]]'.
  Property '2' is missing in type '[number, number]'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(24,4): error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'.
  Type 'string | number' is not assignable to type 'number'.
    Type 'string' is not assignable to type 'number'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(29,17): error TS1317: A parameter property cannot be declared using a rest parameter.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(34,22): error TS2304: Cannot find name 'E1'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(34,28): error TS2304: Cannot find name 'E'.


==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts (12 errors) ====
    // If the parameter is a rest parameter, the parameter type is any[]
    // A type annotation for a rest parameter must denote an array type.
    
    // RestParameter:
    //     ...   Identifier   TypeAnnotation(opt)
    
    type arrayString = Array<String>
    type someArray = Array<String> | number[];
    type stringOrNumArray = Array<String|Number>;
    
    function a0(...x: [number, number, string]) { }  // Error, rest parameter must be array type
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2370: A rest parameter must be of an array type.
    function a1(...x: (number|string)[]) { }
    function a2(...a: someArray) { }  // Error, rest parameter must be array type
                ~~~~~~~~~~~~~~~
!!! error TS2370: A rest parameter must be of an array type.
    function a3(...b?) { }            // Error, can't be optional
                    ~
!!! error TS1047: A rest parameter cannot be optional.
    function a4(...b = [1,2,3]) { }   // Error, can't have initializer
                   ~
!!! error TS1048: A rest parameter cannot have an initializer.
    function a5([a, b, [[c]]]) { }
    function a6([a, b, c, ...x]: number[]) { }
    
    
    a1(1, 2, "hello", true);  // Error, parameter type is (number|string)[]
                      ~~~~
!!! error TS2345: Argument of type 'true' is not assignable to parameter of type 'string | number'.
    a1(...array2);            // Error parameter type is (number|string)[]
          ~~~~~~
!!! error TS2304: Cannot find name 'array2'.
    a5([1, 2, "string", false, true]);       // Error, parameter type is [any, any, [[any]]]
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '[number, number, string, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'.
!!! error TS2345:   Types of property '2' are incompatible.
!!! error TS2345:     Type 'string' is not assignable to type '[[any]]'.
    a5([1, 2]);                              // Error, parameter type is [any, any, [[any]]]
       ~~~~~~
!!! error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]]]'.
!!! error TS2345:   Property '2' is missing in type '[number, number]'.
    a6([1, 2, "string"]);                   // Error, parameter type is number[]
       ~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'.
!!! error TS2345:   Type 'string | number' is not assignable to type 'number'.
!!! error TS2345:     Type 'string' is not assignable to type 'number'.
    
    
    var temp = [1, 2, 3];
    class C {
        constructor(public ...temp) { }  // Error, rest parameter can't have properties
                    ~~~~~~~~~~~~~~
!!! error TS1317: A parameter property cannot be declared using a rest parameter.
    }
    
    // Rest parameter with generic
    function foo1<T extends Number>(...a: T[]) { }
    foo1(1, 2, "string", E1.a, E.b);  // Error
                         ~~
!!! error TS2304: Cannot find name 'E1'.
                               ~
!!! error TS2304: Cannot find name 'E'.