File: destructuringVariableDeclaration2.errors.txt

package info (click to toggle)
node-typescript 2.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 203,952 kB
  • ctags: 52,987
  • sloc: sh: 11; makefile: 5
file content (44 lines) | stat: -rw-r--r-- 3,579 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
tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(3,5): error TS2322: Type '{ a1: boolean; a2: number; }' is not assignable to type '{ a1: number; a2: string; }'.
  Types of property 'a1' are incompatible.
    Type 'boolean' is not assignable to type 'number'.
tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(4,5): error TS2322: Type '[number, [[boolean]], true]' is not assignable to type '[number, [[string]], boolean]'.
  Type '[[boolean]]' is not assignable to type '[[string]]'.
    Type '[boolean]' is not assignable to type '[string]'.
      Type 'boolean' is not assignable to type 'string'.
tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(14,16): error TS2459: Type 'number | { c3: number; c5: number; }' has no property 'c3' and no string index signature.
tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(14,24): error TS2459: Type 'number | { c3: number; c5: number; }' has no property 'c5' and no string index signature.


==== tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts (4 errors) ====
    // The type T associated with a destructuring variable declaration is determined as follows:
    //      If the declaration includes a type annotation, T is that type.
    var {a1, a2}: { a1: number, a2: string } = { a1: true, a2: 1 }               // Error
        ~~~~~~~~
!!! error TS2322: Type '{ a1: boolean; a2: number; }' is not assignable to type '{ a1: number; a2: string; }'.
!!! error TS2322:   Types of property 'a1' are incompatible.
!!! error TS2322:     Type 'boolean' is not assignable to type 'number'.
    var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [[false]], true];  // Error
        ~~~~~~~~~~~~~~~~
!!! error TS2322: Type '[number, [[boolean]], true]' is not assignable to type '[number, [[string]], boolean]'.
!!! error TS2322:   Type '[[boolean]]' is not assignable to type '[[string]]'.
!!! error TS2322:     Type '[boolean]' is not assignable to type '[string]'.
!!! error TS2322:       Type 'boolean' is not assignable to type 'string'.
    
    // The type T associated with a destructuring variable declaration is determined as follows:
    //      Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression.
    var temp = { t1: true, t2: "false" };
    var [b0 = 3, b1 = true, b2 = temp] = [3, false, { t1: false, t2: 5}];  // Error
    
    // The type T associated with a binding element is determined as follows:
    //      If the binding element is a rest element, T is an array type with
    //          an element type E, where E is the type of the numeric index signature of S.
    var [c1, c2, { c3: c4, c5 }, , ...c6] = [1, 2, { c3: 4, c5: 0 }];  // Error
                   ~~
!!! error TS2459: Type 'number | { c3: number; c5: number; }' has no property 'c3' and no string index signature.
                           ~~
!!! error TS2459: Type 'number | { c3: number; c5: number; }' has no property 'c5' and no string index signature.
    
    // When a destructuring variable declaration, binding property, or binding element specifies
    // an initializer expression, the type of the initializer expression is required to be assignable
    // to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element.
    var {d: {d1 = ["string", null]}}: { d: { d1: number[] } } = { d: { d1: [1, 2] } };  // Error