Skip to content

Commit dd63c46

Browse files
committed
Update tests and baselines
1 parent 6c2344e commit dd63c46

File tree

7 files changed

+240
-170
lines changed

7 files changed

+240
-170
lines changed

tests/baselines/reference/controlFlowLetVar.js

Lines changed: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
declare let cond: boolean;
44

5+
// CFA for 'let' with no type annotation and initializer
56
function f1() {
67
let x;
78
if (cond) {
@@ -10,9 +11,10 @@ function f1() {
1011
if (cond) {
1112
x = "hello";
1213
}
13-
const y = x;
14+
const y = x; // string | number | undefined
1415
}
1516

17+
// CFA for 'let' with no type annotation and 'undefined' initializer
1618
function f2() {
1719
let x = undefined;
1820
if (cond) {
@@ -21,9 +23,10 @@ function f2() {
2123
if (cond) {
2224
x = "hello";
2325
}
24-
const y = x;
26+
const y = x; // string | number | undefined
2527
}
2628

29+
// CFA for 'let' with no type annotation and 'null' initializer
2730
function f3() {
2831
let x = null;
2932
if (cond) {
@@ -32,9 +35,10 @@ function f3() {
3235
if (cond) {
3336
x = "hello";
3437
}
35-
const y = x;
38+
const y = x; // string | number | null
3639
}
3740

41+
// No CFA for 'let' with with type annotation
3842
function f4() {
3943
let x: any;
4044
if (cond) {
@@ -43,9 +47,10 @@ function f4() {
4347
if (cond) {
4448
x = "hello";
4549
}
46-
const y = x;
50+
const y = x; // any
4751
}
4852

53+
// CFA for 'var' with no type annotation and initializer
4954
function f5() {
5055
var x;
5156
if (cond) {
@@ -54,9 +59,10 @@ function f5() {
5459
if (cond) {
5560
x = "hello";
5661
}
57-
const y = x;
62+
const y = x; // string | number | undefined
5863
}
5964

65+
// CFA for 'var' with no type annotation and 'undefined' initializer
6066
function f6() {
6167
var x = undefined;
6268
if (cond) {
@@ -65,9 +71,10 @@ function f6() {
6571
if (cond) {
6672
x = "hello";
6773
}
68-
const y = x;
74+
const y = x; // string | number | undefined
6975
}
7076

77+
// CFA for 'var' with no type annotation and 'null' initializer
7178
function f7() {
7279
var x = null;
7380
if (cond) {
@@ -76,9 +83,10 @@ function f7() {
7683
if (cond) {
7784
x = "hello";
7885
}
79-
const y = x;
86+
const y = x; // string | number | null
8087
}
8188

89+
// No CFA for 'var' with with type annotation
8290
function f8() {
8391
var x: any;
8492
if (cond) {
@@ -87,9 +95,10 @@ function f8() {
8795
if (cond) {
8896
x = "hello";
8997
}
90-
const y = x;
98+
const y = x; // any
9199
}
92100

101+
// No CFA for captured outer variables
93102
function f9() {
94103
let x;
95104
if (cond) {
@@ -98,12 +107,13 @@ function f9() {
98107
if (cond) {
99108
x = "hello";
100109
}
101-
const y = x;
110+
const y = x; // string | number | undefined
102111
function f() {
103-
const z = x;
112+
const z = x; // any
104113
}
105114
}
106115

116+
// No CFA for captured outer variables
107117
function f10() {
108118
let x;
109119
if (cond) {
@@ -112,13 +122,14 @@ function f10() {
112122
if (cond) {
113123
x = "hello";
114124
}
115-
const y = x;
125+
const y = x; // string | number | undefined
116126
const f = () => {
117-
const z = x;
127+
const z = x; // any
118128
};
119129
}
120130

121131
//// [controlFlowLetVar.js]
132+
// CFA for 'let' with no type annotation and initializer
122133
function f1() {
123134
var x;
124135
if (cond) {
@@ -127,8 +138,9 @@ function f1() {
127138
if (cond) {
128139
x = "hello";
129140
}
130-
var y = x;
141+
var y = x; // string | number | undefined
131142
}
143+
// CFA for 'let' with no type annotation and 'undefined' initializer
132144
function f2() {
133145
var x = undefined;
134146
if (cond) {
@@ -137,8 +149,9 @@ function f2() {
137149
if (cond) {
138150
x = "hello";
139151
}
140-
var y = x;
152+
var y = x; // string | number | undefined
141153
}
154+
// CFA for 'let' with no type annotation and 'null' initializer
142155
function f3() {
143156
var x = null;
144157
if (cond) {
@@ -147,8 +160,9 @@ function f3() {
147160
if (cond) {
148161
x = "hello";
149162
}
150-
var y = x;
163+
var y = x; // string | number | null
151164
}
165+
// No CFA for 'let' with with type annotation
152166
function f4() {
153167
var x;
154168
if (cond) {
@@ -157,8 +171,9 @@ function f4() {
157171
if (cond) {
158172
x = "hello";
159173
}
160-
var y = x;
174+
var y = x; // any
161175
}
176+
// CFA for 'var' with no type annotation and initializer
162177
function f5() {
163178
var x;
164179
if (cond) {
@@ -167,8 +182,9 @@ function f5() {
167182
if (cond) {
168183
x = "hello";
169184
}
170-
var y = x;
185+
var y = x; // string | number | undefined
171186
}
187+
// CFA for 'var' with no type annotation and 'undefined' initializer
172188
function f6() {
173189
var x = undefined;
174190
if (cond) {
@@ -177,8 +193,9 @@ function f6() {
177193
if (cond) {
178194
x = "hello";
179195
}
180-
var y = x;
196+
var y = x; // string | number | undefined
181197
}
198+
// CFA for 'var' with no type annotation and 'null' initializer
182199
function f7() {
183200
var x = null;
184201
if (cond) {
@@ -187,8 +204,9 @@ function f7() {
187204
if (cond) {
188205
x = "hello";
189206
}
190-
var y = x;
207+
var y = x; // string | number | null
191208
}
209+
// No CFA for 'var' with with type annotation
192210
function f8() {
193211
var x;
194212
if (cond) {
@@ -197,8 +215,9 @@ function f8() {
197215
if (cond) {
198216
x = "hello";
199217
}
200-
var y = x;
218+
var y = x; // any
201219
}
220+
// No CFA for captured outer variables
202221
function f9() {
203222
var x;
204223
if (cond) {
@@ -207,11 +226,12 @@ function f9() {
207226
if (cond) {
208227
x = "hello";
209228
}
210-
var y = x;
229+
var y = x; // string | number | undefined
211230
function f() {
212-
var z = x;
231+
var z = x; // any
213232
}
214233
}
234+
// No CFA for captured outer variables
215235
function f10() {
216236
var x;
217237
if (cond) {
@@ -220,8 +240,8 @@ function f10() {
220240
if (cond) {
221241
x = "hello";
222242
}
223-
var y = x;
243+
var y = x; // string | number | undefined
224244
var f = function () {
225-
var z = x;
245+
var z = x; // any
226246
};
227247
}

0 commit comments

Comments
 (0)