Skip to content

Commit 583edce

Browse files
KingwlRyanCavanaugh
authored andcommitted
fix compiler crash (microsoft#25925)
1 parent e007ccf commit 583edce

File tree

5 files changed

+50
-1
lines changed

5 files changed

+50
-1
lines changed

src/compiler/transformers/ts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2577,7 +2577,7 @@ namespace ts {
25772577
*/
25782578
function visitEnumDeclaration(node: EnumDeclaration): VisitResult<Statement> {
25792579
if (!shouldEmitEnumDeclaration(node)) {
2580-
return undefined;
2580+
return createNotEmittedStatement(node);
25812581
}
25822582

25832583
const statements: Statement[] = [];
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//// [constEnum4.ts]
2+
if (1)
3+
const enum A { }
4+
else if (2)
5+
const enum B { }
6+
else
7+
const enum C { }
8+
9+
10+
//// [constEnum4.js]
11+
if (1)
12+
else if (2)
13+
else
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
=== tests/cases/conformance/constEnums/constEnum4.ts ===
2+
if (1)
3+
const enum A { }
4+
>A : Symbol(A, Decl(constEnum4.ts, 0, 6))
5+
6+
else if (2)
7+
const enum B { }
8+
>B : Symbol(B, Decl(constEnum4.ts, 2, 11))
9+
10+
else
11+
const enum C { }
12+
>C : Symbol(C, Decl(constEnum4.ts, 4, 4))
13+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
=== tests/cases/conformance/constEnums/constEnum4.ts ===
2+
if (1)
3+
>1 : 1
4+
5+
const enum A { }
6+
>A : A
7+
8+
else if (2)
9+
>2 : 2
10+
11+
const enum B { }
12+
>B : B
13+
14+
else
15+
const enum C { }
16+
>C : C
17+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
if (1)
2+
const enum A { }
3+
else if (2)
4+
const enum B { }
5+
else
6+
const enum C { }

0 commit comments

Comments
 (0)