mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
Set the end position of variable statement as -1 so the trailing comments are not emitted
This commit is contained in:
parent
27adb8c363
commit
2e47f22fcc
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user