Skip to content

Commit 68045a3

Browse files
Merge pull request microsoft#1278 from Microsoft/preserveConstEnums2
Emit modules that contain only const enums, if the preserveConstEnum flag is provided.
2 parents 7cb4fef + 498a327 commit 68045a3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/compiler/emitter.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ module ts {
715715
};
716716
}
717717
}
718-
718+
719719
function emitEnumDeclaration(node: EnumDeclaration) {
720720
if (resolver.isDeclarationVisible(node)) {
721721
emitJsDocComments(node);
@@ -3176,7 +3176,10 @@ module ts {
31763176
}
31773177

31783178
function emitModuleDeclaration(node: ModuleDeclaration) {
3179-
if (getModuleInstanceState(node) !== ModuleInstanceState.Instantiated) {
3179+
var shouldEmit = getModuleInstanceState(node) === ModuleInstanceState.Instantiated ||
3180+
(getModuleInstanceState(node) === ModuleInstanceState.ConstEnumOnly && compilerOptions.preserveConstEnums);
3181+
3182+
if (!shouldEmit) {
31803183
return emitPinnedOrTripleSlashComments(node);
31813184
}
31823185
emitLeadingComments(node);
@@ -3558,7 +3561,7 @@ module ts {
35583561
return leadingComments;
35593562
}
35603563

3561-
3564+
35623565
function getLeadingCommentsToEmit(node: Node) {
35633566
// Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments
35643567
if (node.parent.kind === SyntaxKind.SourceFile || node.pos !== node.parent.pos) {

0 commit comments

Comments
 (0)