Set the end position of variable statement as -1 so the trailing comments are not emitted

This commit is contained in:
Sheetal Nandi 2016-04-13 14:14:00 -07:00
parent 27adb8c363
commit 2e47f22fcc
2 changed files with 15 additions and 20 deletions

View File

@ -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);
}

View File

@ -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
)