Fix the trailing comment emit for module declaration

Fixes #8045

Fixes:
- tests\cases\compiler\augmentedTypesClass3.ts
- tests\cases\compiler\augmentedTypesModules.ts
- tests\cases\compiler\commentsModules.ts
This commit is contained in:
Sheetal Nandi 2016-04-13 11:59:29 -07:00
parent 329a9fbab1
commit 7b07d3ce27

View File

@ -117,6 +117,25 @@ namespace ts {
return undefined;
}
const node = range as Node;
if (node.kind === SyntaxKind.VariableStatement &&
node.original &&
node.original.kind === SyntaxKind.ModuleDeclaration) {
// 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);
}