From 498a3274b8f22c39f7683f9452f7a06afde5d02c Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Wed, 26 Nov 2014 01:06:10 -0800 Subject: [PATCH] Emit modules that contain only const enums, if the preserveConstEnum flag is provided. --- src/compiler/emitter.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 5cdf98aa63e..11ecd3a37b8 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -715,7 +715,7 @@ module ts { }; } } - + function emitEnumDeclaration(node: EnumDeclaration) { if (resolver.isDeclarationVisible(node)) { emitJsDocComments(node); @@ -3176,7 +3176,10 @@ module ts { } function emitModuleDeclaration(node: ModuleDeclaration) { - if (getModuleInstanceState(node) !== ModuleInstanceState.Instantiated) { + var shouldEmit = getModuleInstanceState(node) === ModuleInstanceState.Instantiated || + (getModuleInstanceState(node) === ModuleInstanceState.ConstEnumOnly && compilerOptions.preserveConstEnums); + + if (!shouldEmit) { return emitPinnedOrTripleSlashComments(node); } emitLeadingComments(node); @@ -3558,7 +3561,7 @@ module ts { return leadingComments; } - + function getLeadingCommentsToEmit(node: Node) { // Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent.kind === SyntaxKind.SourceFile || node.pos !== node.parent.pos) {