Skip to content

Commit 79ed3a7

Browse files
committed
Accept new baselines
1 parent bfa4197 commit 79ed3a7

8 files changed

+144
-78
lines changed

tests/baselines/reference/arrayLiterals2ES5.types

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,9 @@ var d5 = [...temp3];
194194

195195
var d6 = [...temp4];
196196
>d6 : any[]
197-
>[...temp4] : undefined[]
198-
>...temp4 : undefined
199-
>temp4 : undefined[]
197+
>[...temp4] : any[]
198+
>...temp4 : any
199+
>temp4 : any[]
200200

201201
var d7 = [...[...temp1]];
202202
>d7 : number[]

tests/baselines/reference/controlFlowArrayErrors.errors.txt

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
tests/cases/compiler/controlFlowArrayErrors.ts(6,9): error TS7005: Variable 'y' implicitly has an 'any[]' type.
2-
tests/cases/compiler/controlFlowArrayErrors.ts(14,9): error TS7005: Variable 'y' implicitly has an 'any[]' type.
1+
tests/cases/compiler/controlFlowArrayErrors.ts(5,9): error TS7034: Variable 'x' implicitly has type 'any[]' in some locations where its type cannot be determined.
2+
tests/cases/compiler/controlFlowArrayErrors.ts(6,13): error TS7005: Variable 'x' implicitly has an 'any[]' type.
3+
tests/cases/compiler/controlFlowArrayErrors.ts(12,9): error TS7034: Variable 'x' implicitly has type 'any[]' in some locations where its type cannot be determined.
4+
tests/cases/compiler/controlFlowArrayErrors.ts(14,13): error TS7005: Variable 'x' implicitly has an 'any[]' type.
35
tests/cases/compiler/controlFlowArrayErrors.ts(20,9): error TS7034: Variable 'x' implicitly has type 'any[]' in some locations where its type cannot be determined.
46
tests/cases/compiler/controlFlowArrayErrors.ts(23,9): error TS7005: Variable 'x' implicitly has an 'any[]' type.
57
tests/cases/compiler/controlFlowArrayErrors.ts(30,12): error TS2345: Argument of type 'true' is not assignable to parameter of type 'string | number'.
@@ -10,25 +12,29 @@ tests/cases/compiler/controlFlowArrayErrors.ts(61,11): error TS7034: Variable 'x
1012
tests/cases/compiler/controlFlowArrayErrors.ts(64,9): error TS7005: Variable 'x' implicitly has an 'any[]' type.
1113

1214

13-
==== tests/cases/compiler/controlFlowArrayErrors.ts (10 errors) ====
15+
==== tests/cases/compiler/controlFlowArrayErrors.ts (12 errors) ====
1416

1517
declare function cond(): boolean;
1618

1719
function f1() {
18-
let x = [];
19-
let y = x; // Implicit any[] error
20+
let x = []; // Implicit any[] error in some locations
2021
~
21-
!!! error TS7005: Variable 'y' implicitly has an 'any[]' type.
22+
!!! error TS7034: Variable 'x' implicitly has type 'any[]' in some locations where its type cannot be determined.
23+
let y = x; // Implicit any[] error
24+
~
25+
!!! error TS7005: Variable 'x' implicitly has an 'any[]' type.
2226
x.push(5);
2327
let z = x;
2428
}
2529

2630
function f2() {
27-
let x;
28-
x = [];
29-
let y = x; // Implicit any[] error
31+
let x; // Implicit any[] error in some locations
3032
~
31-
!!! error TS7005: Variable 'y' implicitly has an 'any[]' type.
33+
!!! error TS7034: Variable 'x' implicitly has type 'any[]' in some locations where its type cannot be determined.
34+
x = [];
35+
let y = x; // Implicit any[] error
36+
~
37+
!!! error TS7005: Variable 'x' implicitly has an 'any[]' type.
3238
x.push(5);
3339
let z = x;
3440
}
@@ -39,7 +45,7 @@ tests/cases/compiler/controlFlowArrayErrors.ts(64,9): error TS7005: Variable 'x'
3945
!!! error TS7034: Variable 'x' implicitly has type 'any[]' in some locations where its type cannot be determined.
4046
x.push(5);
4147
function g() {
42-
x; // Implicit any[] error
48+
x; // Implicit any[] error
4349
~
4450
!!! error TS7005: Variable 'x' implicitly has an 'any[]' type.
4551
}

tests/baselines/reference/controlFlowArrayErrors.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
declare function cond(): boolean;
44

55
function f1() {
6-
let x = [];
7-
let y = x; // Implicit any[] error
6+
let x = []; // Implicit any[] error in some locations
7+
let y = x; // Implicit any[] error
88
x.push(5);
99
let z = x;
1010
}
1111

1212
function f2() {
13-
let x;
13+
let x; // Implicit any[] error in some locations
1414
x = [];
15-
let y = x; // Implicit any[] error
15+
let y = x; // Implicit any[] error
1616
x.push(5);
1717
let z = x;
1818
}
@@ -21,7 +21,7 @@ function f3() {
2121
let x = []; // Implicit any[] error in some locations
2222
x.push(5);
2323
function g() {
24-
x; // Implicit any[] error
24+
x; // Implicit any[] error
2525
}
2626
}
2727

@@ -68,13 +68,13 @@ function f8() {
6868

6969
//// [controlFlowArrayErrors.js]
7070
function f1() {
71-
var x = [];
71+
var x = []; // Implicit any[] error in some locations
7272
var y = x; // Implicit any[] error
7373
x.push(5);
7474
var z = x;
7575
}
7676
function f2() {
77-
var x;
77+
var x; // Implicit any[] error in some locations
7878
x = [];
7979
var y = x; // Implicit any[] error
8080
x.push(5);

tests/baselines/reference/controlFlowArrays.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,19 @@ function f10() {
114114

115115
function f11() {
116116
let x = [];
117-
return x; // never[]
117+
if (x.length === 0) { // x.length ok on implicit any[]
118+
x.push("hello");
119+
}
120+
return x;
118121
}
119122

120123
function f12() {
121124
let x;
122125
x = [];
123-
return x; // never[]
126+
if (x.length === 0) { // x.length ok on implicit any[]
127+
x.push("hello");
128+
}
129+
return x;
124130
}
125131

126132
function f13() {
@@ -278,12 +284,18 @@ function f10() {
278284
}
279285
function f11() {
280286
var x = [];
281-
return x; // never[]
287+
if (x.length === 0) {
288+
x.push("hello");
289+
}
290+
return x;
282291
}
283292
function f12() {
284293
var x;
285294
x = [];
286-
return x; // never[]
295+
if (x.length === 0) {
296+
x.push("hello");
297+
}
298+
return x;
287299
}
288300
function f13() {
289301
var x = [];

tests/baselines/reference/controlFlowArrays.symbols

Lines changed: 64 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -282,78 +282,98 @@ function f11() {
282282
let x = [];
283283
>x : Symbol(x, Decl(controlFlowArrays.ts, 114, 7))
284284

285-
return x; // never[]
285+
if (x.length === 0) { // x.length ok on implicit any[]
286+
>x.length : Symbol(Array.length, Decl(lib.d.ts, --, --))
287+
>x : Symbol(x, Decl(controlFlowArrays.ts, 114, 7))
288+
>length : Symbol(Array.length, Decl(lib.d.ts, --, --))
289+
290+
x.push("hello");
291+
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
292+
>x : Symbol(x, Decl(controlFlowArrays.ts, 114, 7))
293+
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
294+
}
295+
return x;
286296
>x : Symbol(x, Decl(controlFlowArrays.ts, 114, 7))
287297
}
288298

289299
function f12() {
290-
>f12 : Symbol(f12, Decl(controlFlowArrays.ts, 116, 1))
300+
>f12 : Symbol(f12, Decl(controlFlowArrays.ts, 119, 1))
291301

292302
let x;
293-
>x : Symbol(x, Decl(controlFlowArrays.ts, 119, 7))
303+
>x : Symbol(x, Decl(controlFlowArrays.ts, 122, 7))
294304

295305
x = [];
296-
>x : Symbol(x, Decl(controlFlowArrays.ts, 119, 7))
306+
>x : Symbol(x, Decl(controlFlowArrays.ts, 122, 7))
307+
308+
if (x.length === 0) { // x.length ok on implicit any[]
309+
>x.length : Symbol(Array.length, Decl(lib.d.ts, --, --))
310+
>x : Symbol(x, Decl(controlFlowArrays.ts, 122, 7))
311+
>length : Symbol(Array.length, Decl(lib.d.ts, --, --))
297312

298-
return x; // never[]
299-
>x : Symbol(x, Decl(controlFlowArrays.ts, 119, 7))
313+
x.push("hello");
314+
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
315+
>x : Symbol(x, Decl(controlFlowArrays.ts, 122, 7))
316+
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
317+
}
318+
return x;
319+
>x : Symbol(x, Decl(controlFlowArrays.ts, 122, 7))
300320
}
301321

302322
function f13() {
303-
>f13 : Symbol(f13, Decl(controlFlowArrays.ts, 122, 1))
323+
>f13 : Symbol(f13, Decl(controlFlowArrays.ts, 128, 1))
304324

305325
var x = [];
306-
>x : Symbol(x, Decl(controlFlowArrays.ts, 125, 7))
326+
>x : Symbol(x, Decl(controlFlowArrays.ts, 131, 7))
307327

308328
x.push(5);
309329
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
310-
>x : Symbol(x, Decl(controlFlowArrays.ts, 125, 7))
330+
>x : Symbol(x, Decl(controlFlowArrays.ts, 131, 7))
311331
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
312332

313333
x.push("hello");
314334
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
315-
>x : Symbol(x, Decl(controlFlowArrays.ts, 125, 7))
335+
>x : Symbol(x, Decl(controlFlowArrays.ts, 131, 7))
316336
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
317337

318338
x.push(true);
319339
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
320-
>x : Symbol(x, Decl(controlFlowArrays.ts, 125, 7))
340+
>x : Symbol(x, Decl(controlFlowArrays.ts, 131, 7))
321341
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
322342

323343
return x; // (string | number | boolean)[]
324-
>x : Symbol(x, Decl(controlFlowArrays.ts, 125, 7))
344+
>x : Symbol(x, Decl(controlFlowArrays.ts, 131, 7))
325345
}
326346

327347
function f14() {
328-
>f14 : Symbol(f14, Decl(controlFlowArrays.ts, 130, 1))
348+
>f14 : Symbol(f14, Decl(controlFlowArrays.ts, 136, 1))
329349

330350
const x = [];
331-
>x : Symbol(x, Decl(controlFlowArrays.ts, 133, 9))
351+
>x : Symbol(x, Decl(controlFlowArrays.ts, 139, 9))
332352

333353
x.push(5);
334354
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
335-
>x : Symbol(x, Decl(controlFlowArrays.ts, 133, 9))
355+
>x : Symbol(x, Decl(controlFlowArrays.ts, 139, 9))
336356
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
337357

338358
x.push("hello");
339359
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
340-
>x : Symbol(x, Decl(controlFlowArrays.ts, 133, 9))
360+
>x : Symbol(x, Decl(controlFlowArrays.ts, 139, 9))
341361
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
342362

343363
x.push(true);
344364
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
345-
>x : Symbol(x, Decl(controlFlowArrays.ts, 133, 9))
365+
>x : Symbol(x, Decl(controlFlowArrays.ts, 139, 9))
346366
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
347367

348368
return x; // (string | number | boolean)[]
349-
>x : Symbol(x, Decl(controlFlowArrays.ts, 133, 9))
369+
>x : Symbol(x, Decl(controlFlowArrays.ts, 139, 9))
350370
}
351371

352372
function f15() {
353-
>f15 : Symbol(f15, Decl(controlFlowArrays.ts, 138, 1))
373+
>f15 : Symbol(f15, Decl(controlFlowArrays.ts, 144, 1))
354374

355375
let x = [];
356-
>x : Symbol(x, Decl(controlFlowArrays.ts, 141, 7))
376+
>x : Symbol(x, Decl(controlFlowArrays.ts, 147, 7))
357377

358378
while (cond()) {
359379
>cond : Symbol(cond, Decl(controlFlowArrays.ts, 0, 0))
@@ -363,88 +383,88 @@ function f15() {
363383

364384
x.push("hello");
365385
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
366-
>x : Symbol(x, Decl(controlFlowArrays.ts, 141, 7))
386+
>x : Symbol(x, Decl(controlFlowArrays.ts, 147, 7))
367387
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
368388
}
369389
return x; // string[]
370-
>x : Symbol(x, Decl(controlFlowArrays.ts, 141, 7))
390+
>x : Symbol(x, Decl(controlFlowArrays.ts, 147, 7))
371391
}
372392

373393
function f16() {
374-
>f16 : Symbol(f16, Decl(controlFlowArrays.ts, 147, 1))
394+
>f16 : Symbol(f16, Decl(controlFlowArrays.ts, 153, 1))
375395

376396
let x;
377-
>x : Symbol(x, Decl(controlFlowArrays.ts, 150, 7))
397+
>x : Symbol(x, Decl(controlFlowArrays.ts, 156, 7))
378398

379399
let y;
380-
>y : Symbol(y, Decl(controlFlowArrays.ts, 151, 7))
400+
>y : Symbol(y, Decl(controlFlowArrays.ts, 157, 7))
381401

382402
(x = [], x).push(5);
383403
>(x = [], x).push : Symbol(Array.push, Decl(lib.d.ts, --, --))
384-
>x : Symbol(x, Decl(controlFlowArrays.ts, 150, 7))
385-
>x : Symbol(x, Decl(controlFlowArrays.ts, 150, 7))
404+
>x : Symbol(x, Decl(controlFlowArrays.ts, 156, 7))
405+
>x : Symbol(x, Decl(controlFlowArrays.ts, 156, 7))
386406
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
387407

388408
(x.push("hello"), x).push(true);
389409
>(x.push("hello"), x).push : Symbol(Array.push, Decl(lib.d.ts, --, --))
390410
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
391-
>x : Symbol(x, Decl(controlFlowArrays.ts, 150, 7))
411+
>x : Symbol(x, Decl(controlFlowArrays.ts, 156, 7))
392412
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
393-
>x : Symbol(x, Decl(controlFlowArrays.ts, 150, 7))
413+
>x : Symbol(x, Decl(controlFlowArrays.ts, 156, 7))
394414
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
395415

396416
((x))[3] = { a: 1 };
397-
>x : Symbol(x, Decl(controlFlowArrays.ts, 150, 7))
398-
>a : Symbol(a, Decl(controlFlowArrays.ts, 154, 16))
417+
>x : Symbol(x, Decl(controlFlowArrays.ts, 156, 7))
418+
>a : Symbol(a, Decl(controlFlowArrays.ts, 160, 16))
399419

400420
return x; // (string | number | boolean | { a: number })[]
401-
>x : Symbol(x, Decl(controlFlowArrays.ts, 150, 7))
421+
>x : Symbol(x, Decl(controlFlowArrays.ts, 156, 7))
402422
}
403423

404424
function f17() {
405-
>f17 : Symbol(f17, Decl(controlFlowArrays.ts, 156, 1))
425+
>f17 : Symbol(f17, Decl(controlFlowArrays.ts, 162, 1))
406426

407427
let x = [];
408-
>x : Symbol(x, Decl(controlFlowArrays.ts, 159, 7))
428+
>x : Symbol(x, Decl(controlFlowArrays.ts, 165, 7))
409429

410430
x.unshift(5);
411431
>x.unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --))
412-
>x : Symbol(x, Decl(controlFlowArrays.ts, 159, 7))
432+
>x : Symbol(x, Decl(controlFlowArrays.ts, 165, 7))
413433
>unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --))
414434

415435
x.unshift("hello");
416436
>x.unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --))
417-
>x : Symbol(x, Decl(controlFlowArrays.ts, 159, 7))
437+
>x : Symbol(x, Decl(controlFlowArrays.ts, 165, 7))
418438
>unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --))
419439

420440
x.unshift(true);
421441
>x.unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --))
422-
>x : Symbol(x, Decl(controlFlowArrays.ts, 159, 7))
442+
>x : Symbol(x, Decl(controlFlowArrays.ts, 165, 7))
423443
>unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --))
424444

425445
return x; // (string | number | boolean)[]
426-
>x : Symbol(x, Decl(controlFlowArrays.ts, 159, 7))
446+
>x : Symbol(x, Decl(controlFlowArrays.ts, 165, 7))
427447
}
428448

429449
function f18() {
430-
>f18 : Symbol(f18, Decl(controlFlowArrays.ts, 164, 1))
450+
>f18 : Symbol(f18, Decl(controlFlowArrays.ts, 170, 1))
431451

432452
let x = [];
433-
>x : Symbol(x, Decl(controlFlowArrays.ts, 167, 7))
453+
>x : Symbol(x, Decl(controlFlowArrays.ts, 173, 7))
434454

435455
x.push(5);
436456
>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
437-
>x : Symbol(x, Decl(controlFlowArrays.ts, 167, 7))
457+
>x : Symbol(x, Decl(controlFlowArrays.ts, 173, 7))
438458
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
439459

440460
x.unshift("hello");
441461
>x.unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --))
442-
>x : Symbol(x, Decl(controlFlowArrays.ts, 167, 7))
462+
>x : Symbol(x, Decl(controlFlowArrays.ts, 173, 7))
443463
>unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --))
444464

445465
x[2] = true;
446-
>x : Symbol(x, Decl(controlFlowArrays.ts, 167, 7))
466+
>x : Symbol(x, Decl(controlFlowArrays.ts, 173, 7))
447467

448468
return x; // (string | number | boolean)[]
449-
>x : Symbol(x, Decl(controlFlowArrays.ts, 167, 7))
469+
>x : Symbol(x, Decl(controlFlowArrays.ts, 173, 7))
450470
}

0 commit comments

Comments
 (0)