Add a regression test related to narrowing in plain JS files (#59611)

This commit is contained in:
Mateusz Burzyński 2024-08-13 19:19:46 +02:00 committed by GitHub
parent 01a874a8ba
commit 562b815ba3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 108 additions and 0 deletions

View File

@ -0,0 +1,21 @@
//// [tests/cases/compiler/narrowingPlainJsNoCrash1.ts] ////
//// [index.js]
// https://github.com/microsoft/TypeScript/issues/59594
var a$b = {};
var c, d;
d = a$b;
while (d !== a$b);
while ((c = a$b != a$b)) c.e;
//// [index.js]
// https://github.com/microsoft/TypeScript/issues/59594
var a$b = {};
var c, d;
d = a$b;
while (d !== a$b)
;
while ((c = a$b != a$b))
c.e;

View File

@ -0,0 +1,26 @@
//// [tests/cases/compiler/narrowingPlainJsNoCrash1.ts] ////
=== index.js ===
// https://github.com/microsoft/TypeScript/issues/59594
var a$b = {};
>a$b : Symbol(a$b, Decl(index.js, 2, 3))
var c, d;
>c : Symbol(c, Decl(index.js, 3, 3))
>d : Symbol(d, Decl(index.js, 3, 6))
d = a$b;
>d : Symbol(d, Decl(index.js, 3, 6))
>a$b : Symbol(a$b, Decl(index.js, 2, 3))
while (d !== a$b);
>d : Symbol(d, Decl(index.js, 3, 6))
>a$b : Symbol(a$b, Decl(index.js, 2, 3))
while ((c = a$b != a$b)) c.e;
>c : Symbol(c, Decl(index.js, 3, 3))
>a$b : Symbol(a$b, Decl(index.js, 2, 3))
>a$b : Symbol(a$b, Decl(index.js, 2, 3))
>c : Symbol(c, Decl(index.js, 3, 3))

View File

@ -0,0 +1,48 @@
//// [tests/cases/compiler/narrowingPlainJsNoCrash1.ts] ////
=== index.js ===
// https://github.com/microsoft/TypeScript/issues/59594
var a$b = {};
>a$b : {}
> : ^^
>{} : {}
> : ^^
var c, d;
>c : any
>d : any
d = a$b;
>d = a$b : {}
> : ^^
>d : any
>a$b : {}
> : ^^
while (d !== a$b);
>d !== a$b : boolean
> : ^^^^^^^
>d : {}
> : ^^
>a$b : {}
> : ^^
while ((c = a$b != a$b)) c.e;
>(c = a$b != a$b) : boolean
> : ^^^^^^^
>c = a$b != a$b : boolean
> : ^^^^^^^
>c : any
>a$b != a$b : boolean
> : ^^^^^^^
>a$b : {}
> : ^^
>a$b : {}
> : ^^
>c.e : error
>c : true
> : ^^^^
>e : any
> : ^^^

View File

@ -0,0 +1,13 @@
// @allowJs: true
// @checkJs: false
// @outDir: true
// @filename: index.js
// https://github.com/microsoft/TypeScript/issues/59594
var a$b = {};
var c, d;
d = a$b;
while (d !== a$b);
while ((c = a$b != a$b)) c.e;