Skip to content

Commit 562b815

Browse files
authored
Add a regression test related to narrowing in plain JS files (#59611)
1 parent 01a874a commit 562b815

File tree

4 files changed

+108
-0
lines changed

4 files changed

+108
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//// [tests/cases/compiler/narrowingPlainJsNoCrash1.ts] ////
2+
3+
//// [index.js]
4+
// https://github.com/microsoft/TypeScript/issues/59594
5+
6+
var a$b = {};
7+
var c, d;
8+
d = a$b;
9+
while (d !== a$b);
10+
while ((c = a$b != a$b)) c.e;
11+
12+
13+
//// [index.js]
14+
// https://github.com/microsoft/TypeScript/issues/59594
15+
var a$b = {};
16+
var c, d;
17+
d = a$b;
18+
while (d !== a$b)
19+
;
20+
while ((c = a$b != a$b))
21+
c.e;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//// [tests/cases/compiler/narrowingPlainJsNoCrash1.ts] ////
2+
3+
=== index.js ===
4+
// https://github.com/microsoft/TypeScript/issues/59594
5+
6+
var a$b = {};
7+
>a$b : Symbol(a$b, Decl(index.js, 2, 3))
8+
9+
var c, d;
10+
>c : Symbol(c, Decl(index.js, 3, 3))
11+
>d : Symbol(d, Decl(index.js, 3, 6))
12+
13+
d = a$b;
14+
>d : Symbol(d, Decl(index.js, 3, 6))
15+
>a$b : Symbol(a$b, Decl(index.js, 2, 3))
16+
17+
while (d !== a$b);
18+
>d : Symbol(d, Decl(index.js, 3, 6))
19+
>a$b : Symbol(a$b, Decl(index.js, 2, 3))
20+
21+
while ((c = a$b != a$b)) c.e;
22+
>c : Symbol(c, Decl(index.js, 3, 3))
23+
>a$b : Symbol(a$b, Decl(index.js, 2, 3))
24+
>a$b : Symbol(a$b, Decl(index.js, 2, 3))
25+
>c : Symbol(c, Decl(index.js, 3, 3))
26+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
//// [tests/cases/compiler/narrowingPlainJsNoCrash1.ts] ////
2+
3+
=== index.js ===
4+
// https://github.com/microsoft/TypeScript/issues/59594
5+
6+
var a$b = {};
7+
>a$b : {}
8+
> : ^^
9+
>{} : {}
10+
> : ^^
11+
12+
var c, d;
13+
>c : any
14+
>d : any
15+
16+
d = a$b;
17+
>d = a$b : {}
18+
> : ^^
19+
>d : any
20+
>a$b : {}
21+
> : ^^
22+
23+
while (d !== a$b);
24+
>d !== a$b : boolean
25+
> : ^^^^^^^
26+
>d : {}
27+
> : ^^
28+
>a$b : {}
29+
> : ^^
30+
31+
while ((c = a$b != a$b)) c.e;
32+
>(c = a$b != a$b) : boolean
33+
> : ^^^^^^^
34+
>c = a$b != a$b : boolean
35+
> : ^^^^^^^
36+
>c : any
37+
>a$b != a$b : boolean
38+
> : ^^^^^^^
39+
>a$b : {}
40+
> : ^^
41+
>a$b : {}
42+
> : ^^
43+
>c.e : error
44+
>c : true
45+
> : ^^^^
46+
>e : any
47+
> : ^^^
48+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// @allowJs: true
2+
// @checkJs: false
3+
// @outDir: true
4+
5+
// @filename: index.js
6+
7+
// https://github.com/microsoft/TypeScript/issues/59594
8+
9+
var a$b = {};
10+
var c, d;
11+
d = a$b;
12+
while (d !== a$b);
13+
while ((c = a$b != a$b)) c.e;

0 commit comments

Comments
 (0)