Skip to content

Commit 7980489

Browse files
committed
Accept new baselines
1 parent 7b1ca04 commit 7980489

File tree

3 files changed

+179
-0
lines changed

3 files changed

+179
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//// [controlFlowWithIncompleteTypes.ts]
2+
// Repro from #11000
3+
4+
declare var cond: boolean;
5+
6+
function foo1() {
7+
let x: string | number | boolean = 0;
8+
while (cond) {
9+
if (typeof x === "string") {
10+
x = x.slice();
11+
}
12+
else {
13+
x = "abc";
14+
}
15+
}
16+
}
17+
18+
function foo2() {
19+
let x: string | number | boolean = 0;
20+
while (cond) {
21+
if (typeof x === "number") {
22+
x = "abc";
23+
}
24+
else {
25+
x = x.slice();
26+
}
27+
}
28+
}
29+
30+
//// [controlFlowWithIncompleteTypes.js]
31+
// Repro from #11000
32+
function foo1() {
33+
var x = 0;
34+
while (cond) {
35+
if (typeof x === "string") {
36+
x = x.slice();
37+
}
38+
else {
39+
x = "abc";
40+
}
41+
}
42+
}
43+
function foo2() {
44+
var x = 0;
45+
while (cond) {
46+
if (typeof x === "number") {
47+
x = "abc";
48+
}
49+
else {
50+
x = x.slice();
51+
}
52+
}
53+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
=== tests/cases/compiler/controlFlowWithIncompleteTypes.ts ===
2+
// Repro from #11000
3+
4+
declare var cond: boolean;
5+
>cond : Symbol(cond, Decl(controlFlowWithIncompleteTypes.ts, 2, 11))
6+
7+
function foo1() {
8+
>foo1 : Symbol(foo1, Decl(controlFlowWithIncompleteTypes.ts, 2, 26))
9+
10+
let x: string | number | boolean = 0;
11+
>x : Symbol(x, Decl(controlFlowWithIncompleteTypes.ts, 5, 7))
12+
13+
while (cond) {
14+
>cond : Symbol(cond, Decl(controlFlowWithIncompleteTypes.ts, 2, 11))
15+
16+
if (typeof x === "string") {
17+
>x : Symbol(x, Decl(controlFlowWithIncompleteTypes.ts, 5, 7))
18+
19+
x = x.slice();
20+
>x : Symbol(x, Decl(controlFlowWithIncompleteTypes.ts, 5, 7))
21+
>x.slice : Symbol(String.slice, Decl(lib.d.ts, --, --))
22+
>x : Symbol(x, Decl(controlFlowWithIncompleteTypes.ts, 5, 7))
23+
>slice : Symbol(String.slice, Decl(lib.d.ts, --, --))
24+
}
25+
else {
26+
x = "abc";
27+
>x : Symbol(x, Decl(controlFlowWithIncompleteTypes.ts, 5, 7))
28+
}
29+
}
30+
}
31+
32+
function foo2() {
33+
>foo2 : Symbol(foo2, Decl(controlFlowWithIncompleteTypes.ts, 14, 1))
34+
35+
let x: string | number | boolean = 0;
36+
>x : Symbol(x, Decl(controlFlowWithIncompleteTypes.ts, 17, 7))
37+
38+
while (cond) {
39+
>cond : Symbol(cond, Decl(controlFlowWithIncompleteTypes.ts, 2, 11))
40+
41+
if (typeof x === "number") {
42+
>x : Symbol(x, Decl(controlFlowWithIncompleteTypes.ts, 17, 7))
43+
44+
x = "abc";
45+
>x : Symbol(x, Decl(controlFlowWithIncompleteTypes.ts, 17, 7))
46+
}
47+
else {
48+
x = x.slice();
49+
>x : Symbol(x, Decl(controlFlowWithIncompleteTypes.ts, 17, 7))
50+
>x.slice : Symbol(String.slice, Decl(lib.d.ts, --, --))
51+
>x : Symbol(x, Decl(controlFlowWithIncompleteTypes.ts, 17, 7))
52+
>slice : Symbol(String.slice, Decl(lib.d.ts, --, --))
53+
}
54+
}
55+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
=== tests/cases/compiler/controlFlowWithIncompleteTypes.ts ===
2+
// Repro from #11000
3+
4+
declare var cond: boolean;
5+
>cond : boolean
6+
7+
function foo1() {
8+
>foo1 : () => void
9+
10+
let x: string | number | boolean = 0;
11+
>x : string | number | boolean
12+
>0 : 0
13+
14+
while (cond) {
15+
>cond : boolean
16+
17+
if (typeof x === "string") {
18+
>typeof x === "string" : boolean
19+
>typeof x : string
20+
>x : string | number
21+
>"string" : "string"
22+
23+
x = x.slice();
24+
>x = x.slice() : string
25+
>x : string | number | boolean
26+
>x.slice() : string
27+
>x.slice : (start?: number, end?: number) => string
28+
>x : string
29+
>slice : (start?: number, end?: number) => string
30+
}
31+
else {
32+
x = "abc";
33+
>x = "abc" : "abc"
34+
>x : string | number | boolean
35+
>"abc" : "abc"
36+
}
37+
}
38+
}
39+
40+
function foo2() {
41+
>foo2 : () => void
42+
43+
let x: string | number | boolean = 0;
44+
>x : string | number | boolean
45+
>0 : 0
46+
47+
while (cond) {
48+
>cond : boolean
49+
50+
if (typeof x === "number") {
51+
>typeof x === "number" : boolean
52+
>typeof x : string
53+
>x : string | number
54+
>"number" : "number"
55+
56+
x = "abc";
57+
>x = "abc" : "abc"
58+
>x : string | number | boolean
59+
>"abc" : "abc"
60+
}
61+
else {
62+
x = x.slice();
63+
>x = x.slice() : string
64+
>x : string | number | boolean
65+
>x.slice() : string
66+
>x.slice : (start?: number, end?: number) => string
67+
>x : string
68+
>slice : (start?: number, end?: number) => string
69+
}
70+
}
71+
}

0 commit comments

Comments
 (0)