Skip to content

Commit 8dcf8a6

Browse files
authored
Add semicolon to unused class member list (#21495)
Turns out SemicolonClassElement is a specific kind for semicolons inside a class. Having one of them with --noUnusedLocals on would crash the compiler after the assert added in #21013.
1 parent 0951a94 commit 8dcf8a6

File tree

5 files changed

+32
-0
lines changed

5 files changed

+32
-0
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21031,6 +21031,7 @@ namespace ts {
2103121031
}
2103221032
break;
2103321033
case SyntaxKind.IndexSignature:
21034+
case SyntaxKind.SemicolonClassElement:
2103421035
// Can't be private
2103521036
break;
2103621037
default:
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//// [unusedSemicolonInClass.ts]
2+
class Unused {
3+
;
4+
}
5+
6+
7+
//// [unusedSemicolonInClass.js]
8+
var Unused = /** @class */ (function () {
9+
function Unused() {
10+
}
11+
;
12+
return Unused;
13+
}());
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
=== tests/cases/compiler/unusedSemicolonInClass.ts ===
2+
class Unused {
3+
>Unused : Symbol(Unused, Decl(unusedSemicolonInClass.ts, 0, 0))
4+
5+
;
6+
}
7+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
=== tests/cases/compiler/unusedSemicolonInClass.ts ===
2+
class Unused {
3+
>Unused : Unused
4+
5+
;
6+
}
7+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// @noUnusedLocals: true
2+
class Unused {
3+
;
4+
}

0 commit comments

Comments
 (0)