Skip to content

Commit 6a8e78c

Browse files
committed
fix ES6 emit for namespaces to only emit one export binding
1 parent d0fc394 commit 6a8e78c

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

src/compiler/emitter.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6318,15 +6318,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
63186318
const emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node);
63196319

63206320
if (emitVarForModule) {
6321-
emitStart(node);
6322-
if (isES6ExportedDeclaration(node)) {
6323-
write("export ");
6321+
const isES6ExportedNamespace = isES6ExportedDeclaration(node);
6322+
if ((!isES6ExportedNamespace) || !forEach(node.symbol && node.symbol.declarations, declaration => declaration.kind === SyntaxKind.ModuleDeclaration && declaration.pos < node.pos)) {
6323+
emitStart(node);
6324+
if (isES6ExportedNamespace) {
6325+
write("export ");
6326+
}
6327+
write("var ");
6328+
emit(node.name);
6329+
write(";");
6330+
emitEnd(node);
6331+
writeLine();
63246332
}
6325-
write("var ");
6326-
emit(node.name);
6327-
write(";");
6328-
emitEnd(node);
6329-
writeLine();
63306333
}
63316334

63326335
emitStart(node);

tests/baselines/reference/es6ModuleInternalNamedImports2.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ export var M;
5858
// alias
5959
M.M_A = M_M;
6060
})(M || (M = {}));
61-
export var M;
6261
(function (M) {
6362
// Reexports
6463
export { M_V as v };

0 commit comments

Comments
 (0)