File: definiteAssignmentAssertions.symbols

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 (146 lines) | stat: -rw-r--r-- 4,295 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
=== tests/cases/conformance/controlFlow/definiteAssignmentAssertions.ts ===
// Suppress strict property initialization check

class C1 {
>C1 : Symbol(C1, Decl(definiteAssignmentAssertions.ts, 0, 0))

    a!: number;
>a : Symbol(C1.a, Decl(definiteAssignmentAssertions.ts, 2, 10))

    b: string;  // Error
>b : Symbol(C1.b, Decl(definiteAssignmentAssertions.ts, 3, 15))
}

// Suppress definite assignment check in constructor

class C2 {
>C2 : Symbol(C2, Decl(definiteAssignmentAssertions.ts, 5, 1))

    a!: number;
>a : Symbol(C2.a, Decl(definiteAssignmentAssertions.ts, 9, 10))

    constructor() {
        let x = this.a;
>x : Symbol(x, Decl(definiteAssignmentAssertions.ts, 12, 11))
>this.a : Symbol(C2.a, Decl(definiteAssignmentAssertions.ts, 9, 10))
>this : Symbol(C2, Decl(definiteAssignmentAssertions.ts, 5, 1))
>a : Symbol(C2.a, Decl(definiteAssignmentAssertions.ts, 9, 10))
    }
}

// Definite assignment assertion requires type annotation, no initializer, no static modifier

class C3 {
>C3 : Symbol(C3, Decl(definiteAssignmentAssertions.ts, 14, 1))

    a! = 1;
>a : Symbol(C3.a, Decl(definiteAssignmentAssertions.ts, 18, 10))

    b!: number = 1;
>b : Symbol(C3.b, Decl(definiteAssignmentAssertions.ts, 19, 11))

    static c!: number;
>c : Symbol(C3.c, Decl(definiteAssignmentAssertions.ts, 20, 19))
}

// Definite assignment assertion not permitted in ambient context

declare class C4 {
>C4 : Symbol(C4, Decl(definiteAssignmentAssertions.ts, 22, 1))

    a!: number;
>a : Symbol(C4.a, Decl(definiteAssignmentAssertions.ts, 26, 18))
}

// Definite assignment assertion not permitted on abstract property

abstract class C5 {
>C5 : Symbol(C5, Decl(definiteAssignmentAssertions.ts, 28, 1))

    abstract a!: number;
>a : Symbol(C5.a, Decl(definiteAssignmentAssertions.ts, 32, 19))
}

// Suppress definite assignment check for variable

function f1() {
>f1 : Symbol(f1, Decl(definiteAssignmentAssertions.ts, 34, 1))

    let x!: number;
>x : Symbol(x, Decl(definiteAssignmentAssertions.ts, 39, 7))

    let y = x;
>y : Symbol(y, Decl(definiteAssignmentAssertions.ts, 40, 7))
>x : Symbol(x, Decl(definiteAssignmentAssertions.ts, 39, 7))

    var a!: number;
>a : Symbol(a, Decl(definiteAssignmentAssertions.ts, 41, 7))

    var b = a;
>b : Symbol(b, Decl(definiteAssignmentAssertions.ts, 42, 7))
>a : Symbol(a, Decl(definiteAssignmentAssertions.ts, 41, 7))
}

function f2() {
>f2 : Symbol(f2, Decl(definiteAssignmentAssertions.ts, 43, 1))

    let x!: string | number;
>x : Symbol(x, Decl(definiteAssignmentAssertions.ts, 46, 7))

    if (typeof x === "string") {
>x : Symbol(x, Decl(definiteAssignmentAssertions.ts, 46, 7))

        let s: string = x;
>s : Symbol(s, Decl(definiteAssignmentAssertions.ts, 48, 11))
>x : Symbol(x, Decl(definiteAssignmentAssertions.ts, 46, 7))
    }
    else {
        let n: number = x;
>n : Symbol(n, Decl(definiteAssignmentAssertions.ts, 51, 11))
>x : Symbol(x, Decl(definiteAssignmentAssertions.ts, 46, 7))
    }
}

function f3() {
>f3 : Symbol(f3, Decl(definiteAssignmentAssertions.ts, 53, 1))

    let x!: number;
>x : Symbol(x, Decl(definiteAssignmentAssertions.ts, 56, 7))

    const g = () => {
>g : Symbol(g, Decl(definiteAssignmentAssertions.ts, 57, 9))

        x = 1;
>x : Symbol(x, Decl(definiteAssignmentAssertions.ts, 56, 7))
    }
    g();
>g : Symbol(g, Decl(definiteAssignmentAssertions.ts, 57, 9))

    let y = x;
>y : Symbol(y, Decl(definiteAssignmentAssertions.ts, 61, 7))
>x : Symbol(x, Decl(definiteAssignmentAssertions.ts, 56, 7))
}

// Definite assignment assertion requires type annotation and no initializer

function f4() {
>f4 : Symbol(f4, Decl(definiteAssignmentAssertions.ts, 62, 1))

    let a!;
>a : Symbol(a, Decl(definiteAssignmentAssertions.ts, 67, 7))

    let b! = 1;
>b : Symbol(b, Decl(definiteAssignmentAssertions.ts, 68, 7))

    let c!: number = 1;
>c : Symbol(c, Decl(definiteAssignmentAssertions.ts, 69, 7))
}

// Definite assignment assertion not permitted in ambient context

declare let v1!: number;
>v1 : Symbol(v1, Decl(definiteAssignmentAssertions.ts, 74, 11))

declare var v2!: number;
>v2 : Symbol(v2, Decl(definiteAssignmentAssertions.ts, 75, 11))