diff --git a/src/compiler/comments.ts b/src/compiler/comments.ts index f5f8549dd28..1baf1847f04 100644 --- a/src/compiler/comments.ts +++ b/src/compiler/comments.ts @@ -117,25 +117,6 @@ namespace ts { return undefined; } - const node = range as Node; - if (node.kind === SyntaxKind.VariableStatement && - node.original && - (node.original.kind === SyntaxKind.ModuleDeclaration || node.original.kind === SyntaxKind.EnumDeclaration)) { - // Trailing comments for module declaration should be emitted with function closure instead of variable statement - // /** Module comment*/ - // module m1 { - // function foo4Export() { - // } - // } // trailing comment module - // Should emit - // /** Module comment*/ - // var m1; - // (function (m1) { - // function foo4Export() { - // } - // })(m1 || (m1 = {})); // trailing comment module - return undefined; - } return getTrailingCommentsOfPosition(range.end); } diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 8a915484a79..539061dd481 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -2390,7 +2390,21 @@ namespace ts { [createVariableDeclaration( getDeclarationName(node) )], - /*location*/ node + // Trailing comments for module declaration should be emitted with function closure instead of variable statement + // So do not set the end position for the variable statement node + // /** Module comment*/ + // module m1 { + // function foo4Export() { + // } + // } // trailing comment module + // Should emit + // /** Module comment*/ + // var m1; + // (function (m1) { + // function foo4Export() { + // } + // })(m1 || (m1 = {})); // trailing comment module + /*location*/ { pos: node.pos, end: -1 } ), node )