File: destructuringArrayBindingPatternAndAssignment2.errors.txt

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (64 lines) | stat: -rw-r--r-- 4,213 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
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
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,6): error TS2461: Type 'undefined' is not an array type.
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,6): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,12): error TS2461: Type 'undefined' is not an array type.
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,12): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(4,5): error TS2461: Type 'undefined' is not an array type.
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(9,51): error TS2322: Type 'number' is not assignable to type 'boolean'.
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(22,5): error TS2739: Type 'number[]' is missing the following properties from type '[number, number]': 0, 1
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(23,5): error TS2739: Type 'number[]' is missing the following properties from type '[string, string]': 0, 1
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(34,5): error TS2461: Type 'F' is not an array type.


==== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts (9 errors) ====
    // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V,
    //      S is the type Any, or
    var [[a0], [[a1]]] = []         // Error
         ~~~~
!!! error TS2461: Type 'undefined' is not an array type.
         ~~~~
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
               ~~~~~~
!!! error TS2461: Type 'undefined' is not an array type.
               ~~~~~~
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
    var [[a2], [[a3]]] = undefined  // Error
        ~~~~~~~~~~~~~~
!!! error TS2461: Type 'undefined' is not an array type.
    
    // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V,
    //      S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E,
    //        where N is the numeric index of E in the array assignment pattern, or
    var [b0, b1, b2]: [number, boolean, string] = [1, 2, "string"];  // Error
                                                      ~
!!! error TS2322: Type 'number' is not assignable to type 'boolean'.
    interface J extends Array<Number> {
        2: number;
    }
    
    function bar(): J {
        return <[number, number, number]>[1, 2, 3];
    }
    var [b3 = "string", b4, b5] = bar();  // Error
    
    // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V,
    //      S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E.
    var temp = [1, 2, 3]
    var [c0, c1]: [number, number] = [...temp];  // Error
        ~~~~~~~~
!!! error TS2739: Type 'number[]' is missing the following properties from type '[number, number]': 0, 1
    var [c2, c3]: [string, string] = [...temp];  // Error
        ~~~~~~~~
!!! error TS2739: Type 'number[]' is missing the following properties from type '[string, string]': 0, 1
    
    interface F {
        [idx: number]: boolean
    }
    
    function foo(idx: number): F {
        return {
            2: true
        }
    }
    var [c4, c5, c6] = foo(1);  // Error
        ~~~~~~~~~~~~
!!! error TS2461: Type 'F' is not an array type.