Skip to content

Commit 01d6d48

Browse files
committed
Add regression tests
Report unreachable code in JS files when --checkjs is passed, but not otherwise.
1 parent 9d0bbc4 commit 01d6d48

7 files changed

+65
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
tests/cases/compiler/unreachable.js(3,5): error TS7027: Unreachable code detected.
2+
3+
4+
==== tests/cases/compiler/unreachable.js (1 errors) ====
5+
function unreachable() {
6+
return 1;
7+
return 2;
8+
~~~~~~
9+
!!! error TS7027: Unreachable code detected.
10+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//// [unreachable.js]
2+
function unreachable() {
3+
return 1;
4+
return 2;
5+
}
6+
7+
//// [unreachable.js]
8+
function unreachable() {
9+
return 1;
10+
return 2;
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//// [unreachable.js]
2+
function unreachable() {
3+
return 1;
4+
return 2;
5+
}
6+
7+
//// [unreachable.js]
8+
function unreachable() {
9+
return 1;
10+
return 2;
11+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
=== tests/cases/compiler/unreachable.js ===
2+
function unreachable() {
3+
>unreachable : Symbol(unreachable, Decl(unreachable.js, 0, 0))
4+
5+
return 1;
6+
return 2;
7+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
=== tests/cases/compiler/unreachable.js ===
2+
function unreachable() {
3+
>unreachable : () => 1 | 2
4+
5+
return 1;
6+
>1 : 1
7+
8+
return 2;
9+
>2 : 2
10+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// @Filename: unreachable.js
2+
// @allowJs: true
3+
// @checkJs: true
4+
// @outDir: out
5+
function unreachable() {
6+
return 1;
7+
return 2;
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// @Filename: unreachable.js
2+
// @allowJs: true
3+
// @checkJs: false
4+
// @outDir: out
5+
function unreachable() {
6+
return 1;
7+
return 2;
8+
}

0 commit comments

Comments
 (0)