/
strictPropertyInitialization.symbols
377 lines (276 loc) · 12.6 KB
/
strictPropertyInitialization.symbols
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
=== tests/cases/conformance/classes/propertyMemberDeclarations/strictPropertyInitialization.ts ===
// Properties with non-undefined types require initialization
class C1 {
>C1 : Symbol(C1, Decl(strictPropertyInitialization.ts, 0, 0))
a: number; // Error
>a : Symbol(C1.a, Decl(strictPropertyInitialization.ts, 2, 10))
b: number | undefined;
>b : Symbol(C1.b, Decl(strictPropertyInitialization.ts, 3, 14))
c: number | null; // Error
>c : Symbol(C1.c, Decl(strictPropertyInitialization.ts, 4, 26))
d?: number;
>d : Symbol(C1.d, Decl(strictPropertyInitialization.ts, 5, 21))
#f: number; //Error
>#f : Symbol(C1.#f, Decl(strictPropertyInitialization.ts, 6, 15))
#g: number | undefined;
>#g : Symbol(C1.#g, Decl(strictPropertyInitialization.ts, 7, 15))
#h: number | null; //Error
>#h : Symbol(C1.#h, Decl(strictPropertyInitialization.ts, 8, 27))
#i?: number;
>#i : Symbol(C1.#i, Decl(strictPropertyInitialization.ts, 9, 22))
}
// No strict initialization checks in ambient contexts
declare class C2 {
>C2 : Symbol(C2, Decl(strictPropertyInitialization.ts, 11, 1))
a: number;
>a : Symbol(C2.a, Decl(strictPropertyInitialization.ts, 15, 18))
b: number | undefined;
>b : Symbol(C2.b, Decl(strictPropertyInitialization.ts, 16, 14))
c: number | null;
>c : Symbol(C2.c, Decl(strictPropertyInitialization.ts, 17, 26))
d?: number;
>d : Symbol(C2.d, Decl(strictPropertyInitialization.ts, 18, 21))
#f: number;
>#f : Symbol(C2.#f, Decl(strictPropertyInitialization.ts, 19, 15))
#g: number | undefined;
>#g : Symbol(C2.#g, Decl(strictPropertyInitialization.ts, 21, 15))
#h: number | null;
>#h : Symbol(C2.#h, Decl(strictPropertyInitialization.ts, 22, 27))
#i?: number;
>#i : Symbol(C2.#i, Decl(strictPropertyInitialization.ts, 23, 22))
}
// No strict initialization checks for static members
class C3 {
>C3 : Symbol(C3, Decl(strictPropertyInitialization.ts, 25, 1))
static a: number;
>a : Symbol(C3.a, Decl(strictPropertyInitialization.ts, 29, 10))
static b: number | undefined;
>b : Symbol(C3.b, Decl(strictPropertyInitialization.ts, 30, 21))
static c: number | null;
>c : Symbol(C3.c, Decl(strictPropertyInitialization.ts, 31, 33))
static d?: number;
>d : Symbol(C3.d, Decl(strictPropertyInitialization.ts, 32, 28))
}
// Initializer satisfies strict initialization check
class C4 {
>C4 : Symbol(C4, Decl(strictPropertyInitialization.ts, 34, 1))
a = 0;
>a : Symbol(C4.a, Decl(strictPropertyInitialization.ts, 38, 10))
b: number = 0;
>b : Symbol(C4.b, Decl(strictPropertyInitialization.ts, 39, 10))
c: string = "abc";
>c : Symbol(C4.c, Decl(strictPropertyInitialization.ts, 40, 18))
#d = 0
>#d : Symbol(C4.#d, Decl(strictPropertyInitialization.ts, 41, 22))
#e: number = 0
>#e : Symbol(C4.#e, Decl(strictPropertyInitialization.ts, 42, 10))
#f: string= "abc"
>#f : Symbol(C4.#f, Decl(strictPropertyInitialization.ts, 43, 18))
}
// Assignment in constructor satisfies strict initialization check
class C5 {
>C5 : Symbol(C5, Decl(strictPropertyInitialization.ts, 45, 1))
a: number;
>a : Symbol(C5.a, Decl(strictPropertyInitialization.ts, 49, 10))
#b: number;
>#b : Symbol(C5.#b, Decl(strictPropertyInitialization.ts, 50, 14))
constructor() {
this.a = 0;
>this.a : Symbol(C5.a, Decl(strictPropertyInitialization.ts, 49, 10))
>this : Symbol(C5, Decl(strictPropertyInitialization.ts, 45, 1))
>a : Symbol(C5.a, Decl(strictPropertyInitialization.ts, 49, 10))
this.#b = 0;
>this.#b : Symbol(C5.#b, Decl(strictPropertyInitialization.ts, 50, 14))
>this : Symbol(C5, Decl(strictPropertyInitialization.ts, 45, 1))
}
}
// All code paths must contain assignment
class C6 {
>C6 : Symbol(C6, Decl(strictPropertyInitialization.ts, 56, 1))
a: number; // Error
>a : Symbol(C6.a, Decl(strictPropertyInitialization.ts, 60, 10))
#b: number
>#b : Symbol(C6.#b, Decl(strictPropertyInitialization.ts, 61, 14))
constructor(cond: boolean) {
>cond : Symbol(cond, Decl(strictPropertyInitialization.ts, 63, 16))
if (cond) {
>cond : Symbol(cond, Decl(strictPropertyInitialization.ts, 63, 16))
return;
}
this.a = 0;
>this.a : Symbol(C6.a, Decl(strictPropertyInitialization.ts, 60, 10))
>this : Symbol(C6, Decl(strictPropertyInitialization.ts, 56, 1))
>a : Symbol(C6.a, Decl(strictPropertyInitialization.ts, 60, 10))
this.#b = 0;
>this.#b : Symbol(C6.#b, Decl(strictPropertyInitialization.ts, 61, 14))
>this : Symbol(C6, Decl(strictPropertyInitialization.ts, 56, 1))
}
}
class C7 {
>C7 : Symbol(C7, Decl(strictPropertyInitialization.ts, 70, 1))
a: number;
>a : Symbol(C7.a, Decl(strictPropertyInitialization.ts, 72, 10))
#b: number;
>#b : Symbol(C7.#b, Decl(strictPropertyInitialization.ts, 73, 14))
constructor(cond: boolean) {
>cond : Symbol(cond, Decl(strictPropertyInitialization.ts, 75, 16))
if (cond) {
>cond : Symbol(cond, Decl(strictPropertyInitialization.ts, 75, 16))
this.a = 1;
>this.a : Symbol(C7.a, Decl(strictPropertyInitialization.ts, 72, 10))
>this : Symbol(C7, Decl(strictPropertyInitialization.ts, 70, 1))
>a : Symbol(C7.a, Decl(strictPropertyInitialization.ts, 72, 10))
this.#b = 1;
>this.#b : Symbol(C7.#b, Decl(strictPropertyInitialization.ts, 73, 14))
>this : Symbol(C7, Decl(strictPropertyInitialization.ts, 70, 1))
return;
}
this.a = 0;
>this.a : Symbol(C7.a, Decl(strictPropertyInitialization.ts, 72, 10))
>this : Symbol(C7, Decl(strictPropertyInitialization.ts, 70, 1))
>a : Symbol(C7.a, Decl(strictPropertyInitialization.ts, 72, 10))
this.#b = 1;
>this.#b : Symbol(C7.#b, Decl(strictPropertyInitialization.ts, 73, 14))
>this : Symbol(C7, Decl(strictPropertyInitialization.ts, 70, 1))
}
}
// Properties with string literal names aren't checked
class C8 {
>C8 : Symbol(C8, Decl(strictPropertyInitialization.ts, 84, 1))
a: number; // Error
>a : Symbol(C8.a, Decl(strictPropertyInitialization.ts, 88, 10))
"b": number;
>"b" : Symbol(C8["b"], Decl(strictPropertyInitialization.ts, 89, 14))
0: number;
>0 : Symbol(C8[0], Decl(strictPropertyInitialization.ts, 90, 16))
}
// No strict initialization checks for abstract members
abstract class C9 {
>C9 : Symbol(C9, Decl(strictPropertyInitialization.ts, 92, 1))
abstract a: number;
>a : Symbol(C9.a, Decl(strictPropertyInitialization.ts, 96, 19))
abstract b: number | undefined;
>b : Symbol(C9.b, Decl(strictPropertyInitialization.ts, 97, 23))
abstract c: number | null;
>c : Symbol(C9.c, Decl(strictPropertyInitialization.ts, 98, 35))
abstract d?: number;
>d : Symbol(C9.d, Decl(strictPropertyInitialization.ts, 99, 30))
}
// Properties with non-undefined types must be assigned before they can be accessed
// within their constructor
class C10 {
>C10 : Symbol(C10, Decl(strictPropertyInitialization.ts, 101, 1))
a: number;
>a : Symbol(C10.a, Decl(strictPropertyInitialization.ts, 106, 11))
b: number;
>b : Symbol(C10.b, Decl(strictPropertyInitialization.ts, 107, 14))
c?: number;
>c : Symbol(C10.c, Decl(strictPropertyInitialization.ts, 108, 14))
#d: number;
>#d : Symbol(C10.#d, Decl(strictPropertyInitialization.ts, 109, 15))
constructor() {
let x = this.a; // Error
>x : Symbol(x, Decl(strictPropertyInitialization.ts, 112, 11))
>this.a : Symbol(C10.a, Decl(strictPropertyInitialization.ts, 106, 11))
>this : Symbol(C10, Decl(strictPropertyInitialization.ts, 101, 1))
>a : Symbol(C10.a, Decl(strictPropertyInitialization.ts, 106, 11))
this.a = this.b; // Error
>this.a : Symbol(C10.a, Decl(strictPropertyInitialization.ts, 106, 11))
>this : Symbol(C10, Decl(strictPropertyInitialization.ts, 101, 1))
>a : Symbol(C10.a, Decl(strictPropertyInitialization.ts, 106, 11))
>this.b : Symbol(C10.b, Decl(strictPropertyInitialization.ts, 107, 14))
>this : Symbol(C10, Decl(strictPropertyInitialization.ts, 101, 1))
>b : Symbol(C10.b, Decl(strictPropertyInitialization.ts, 107, 14))
this.b = this.#d //Error
>this.b : Symbol(C10.b, Decl(strictPropertyInitialization.ts, 107, 14))
>this : Symbol(C10, Decl(strictPropertyInitialization.ts, 101, 1))
>b : Symbol(C10.b, Decl(strictPropertyInitialization.ts, 107, 14))
>this.#d : Symbol(C10.#d, Decl(strictPropertyInitialization.ts, 109, 15))
>this : Symbol(C10, Decl(strictPropertyInitialization.ts, 101, 1))
this.b = x;
>this.b : Symbol(C10.b, Decl(strictPropertyInitialization.ts, 107, 14))
>this : Symbol(C10, Decl(strictPropertyInitialization.ts, 101, 1))
>b : Symbol(C10.b, Decl(strictPropertyInitialization.ts, 107, 14))
>x : Symbol(x, Decl(strictPropertyInitialization.ts, 112, 11))
this.#d = x;
>this.#d : Symbol(C10.#d, Decl(strictPropertyInitialization.ts, 109, 15))
>this : Symbol(C10, Decl(strictPropertyInitialization.ts, 101, 1))
>x : Symbol(x, Decl(strictPropertyInitialization.ts, 112, 11))
let y = this.c;
>y : Symbol(y, Decl(strictPropertyInitialization.ts, 117, 11))
>this.c : Symbol(C10.c, Decl(strictPropertyInitialization.ts, 108, 14))
>this : Symbol(C10, Decl(strictPropertyInitialization.ts, 101, 1))
>c : Symbol(C10.c, Decl(strictPropertyInitialization.ts, 108, 14))
}
}
// Property is considered initialized by type any even though value could be undefined
declare function someValue(): any;
>someValue : Symbol(someValue, Decl(strictPropertyInitialization.ts, 119, 1))
class C11 {
>C11 : Symbol(C11, Decl(strictPropertyInitialization.ts, 123, 34))
a: number;
>a : Symbol(C11.a, Decl(strictPropertyInitialization.ts, 125, 11))
#b: number;
>#b : Symbol(C11.#b, Decl(strictPropertyInitialization.ts, 126, 14))
constructor() {
this.a = someValue();
>this.a : Symbol(C11.a, Decl(strictPropertyInitialization.ts, 125, 11))
>this : Symbol(C11, Decl(strictPropertyInitialization.ts, 123, 34))
>a : Symbol(C11.a, Decl(strictPropertyInitialization.ts, 125, 11))
>someValue : Symbol(someValue, Decl(strictPropertyInitialization.ts, 119, 1))
this.#b = someValue();
>this.#b : Symbol(C11.#b, Decl(strictPropertyInitialization.ts, 126, 14))
>this : Symbol(C11, Decl(strictPropertyInitialization.ts, 123, 34))
>someValue : Symbol(someValue, Decl(strictPropertyInitialization.ts, 119, 1))
}
}
const a = 'a';
>a : Symbol(a, Decl(strictPropertyInitialization.ts, 134, 5))
const b = Symbol();
>b : Symbol(b, Decl(strictPropertyInitialization.ts, 135, 5))
>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
class C12 {
>C12 : Symbol(C12, Decl(strictPropertyInitialization.ts, 135, 19))
[a]: number;
>[a] : Symbol(C12[a], Decl(strictPropertyInitialization.ts, 137, 11))
>a : Symbol(a, Decl(strictPropertyInitialization.ts, 134, 5))
[b]: number;
>[b] : Symbol(C12[b], Decl(strictPropertyInitialization.ts, 138, 16))
>b : Symbol(b, Decl(strictPropertyInitialization.ts, 135, 5))
['c']: number;
>['c'] : Symbol(C12['c'], Decl(strictPropertyInitialization.ts, 139, 16))
>'c' : Symbol(C12['c'], Decl(strictPropertyInitialization.ts, 139, 16))
constructor() {
this[a] = 1;
>this : Symbol(C12, Decl(strictPropertyInitialization.ts, 135, 19))
>a : Symbol(a, Decl(strictPropertyInitialization.ts, 134, 5))
this[b] = 1;
>this : Symbol(C12, Decl(strictPropertyInitialization.ts, 135, 19))
>b : Symbol(b, Decl(strictPropertyInitialization.ts, 135, 5))
this['c'] = 1;
>this : Symbol(C12, Decl(strictPropertyInitialization.ts, 135, 19))
>'c' : Symbol(C12['c'], Decl(strictPropertyInitialization.ts, 139, 16))
}
}
enum E {
>E : Symbol(E, Decl(strictPropertyInitialization.ts, 147, 1))
A = "A",
>A : Symbol(E.A, Decl(strictPropertyInitialization.ts, 149, 8))
B = "B"
>B : Symbol(E.B, Decl(strictPropertyInitialization.ts, 150, 12))
}
class C13 {
>C13 : Symbol(C13, Decl(strictPropertyInitialization.ts, 152, 1))
[E.A]: number;
>[E.A] : Symbol(C13[E.A], Decl(strictPropertyInitialization.ts, 153, 11))
>E.A : Symbol(E.A, Decl(strictPropertyInitialization.ts, 149, 8))
>E : Symbol(E, Decl(strictPropertyInitialization.ts, 147, 1))
>A : Symbol(E.A, Decl(strictPropertyInitialization.ts, 149, 8))
constructor() {
this[E.A] = 1;
>this : Symbol(C13, Decl(strictPropertyInitialization.ts, 152, 1))
>E.A : Symbol(E.A, Decl(strictPropertyInitialization.ts, 149, 8))
>E : Symbol(E, Decl(strictPropertyInitialization.ts, 147, 1))
>A : Symbol(E.A, Decl(strictPropertyInitialization.ts, 149, 8))
}
}