File: destructuringControlFlow.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 (47 lines) | stat: -rw-r--r-- 1,772 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
tests/cases/conformance/es6/destructuring/destructuringControlFlow.ts(31,8): error TS2339: Property 'x' does not exist on type 'Number'.
tests/cases/conformance/es6/destructuring/destructuringControlFlow.ts(32,9): error TS2339: Property 'x' does not exist on type 'Number'.
tests/cases/conformance/es6/destructuring/destructuringControlFlow.ts(33,9): error TS2537: Type 'Number' has no matching index signature for type 'string'.


==== tests/cases/conformance/es6/destructuring/destructuringControlFlow.ts (3 errors) ====
    function f1(obj: { a?: string }) {
        if (obj.a) {
            obj = {};
            let a1 = obj["a"];  // string | undefined
            let a2 = obj.a;  // string | undefined
        }
    }
    
    function f2(obj: [number, string] | null[]) {
        let a0 = obj[0];  // number | null
        let a1 = obj[1];  // string | null
        let [b0, b1] = obj;
        ([a0, a1] = obj);
        if (obj[0] && obj[1]) {
            let c0 = obj[0];  // number
            let c1 = obj[1];  // string
            let [d0, d1] = obj;
            ([c0, c1] = obj);
        }
    }
    
    function f3(obj: { a?: number, b?: string }) {
        if (obj.a && obj.b) {
            let { a, b } = obj;  // number, string
            ({ a, b } = obj);
        }
    }
    
    function f4() {
        let x: boolean;
        ({ x } = 0);  // Error
           ~
!!! error TS2339: Property 'x' does not exist on type 'Number'.
        ({ ["x"]: x } = 0);  // Error
            ~~~
!!! error TS2339: Property 'x' does not exist on type 'Number'.
        ({ ["x" + ""]: x } = 0);  // Errpr
            ~~~~~~~~
!!! error TS2537: Type 'Number' has no matching index signature for type 'string'.
    }