Skip to content

Commit bcdbfd7

Browse files
committed
[Transforms] fix8155 : Hoist exported enum in system output (microsoft#8177)
* Hoist exported enum in system output * Update baselines
1 parent c454715 commit bcdbfd7

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/compiler/transformers/module/system.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,12 @@ namespace ts {
675675
const originalNode = getOriginalNode(node);
676676
if ((originalNode.kind === SyntaxKind.ModuleDeclaration || originalNode.kind === SyntaxKind.EnumDeclaration) && hasModifier(originalNode, ModifierFlags.Export)) {
677677
const name = getDeclarationName(<ModuleDeclaration | EnumDeclaration>originalNode);
678+
// We only need to hoistVariableDeclaration for EnumDeclaration
679+
// as ModuleDeclaration is already hoisted when the transformer call visitVariableStatement
680+
// which then call transformsVariable for each declaration in declarationList
681+
if (originalNode.kind === SyntaxKind.EnumDeclaration) {
682+
hoistVariableDeclaration(name);
683+
}
678684
return [
679685
node,
680686
createExportStatement(name, name)

tests/baselines/reference/systemModuleDeclarationMerging.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ System.register([], function (exports_1, context_1) {
1414
"use strict";
1515
var __moduleName = context_1 && context_1.id;
1616
function F() { }
17-
var F, C, C, E;
17+
var F, C, C, E, E;
1818
exports_1("F", F);
1919
return {
2020
setters: [],

0 commit comments

Comments
 (0)