File tree Expand file tree Collapse file tree
src/compiler/transformers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2859,7 +2859,6 @@ namespace ts {
28592859 const moduleBlock = < ModuleBlock > getInnerMostModuleDeclarationFromDottedModule ( node ) . body ;
28602860 statementsLocation = moveRangePos ( moduleBlock . statements , - 1 ) ;
28612861 }
2862-
28632862 addRange ( statements , endLexicalEnvironment ( ) ) ;
28642863
28652864 currentNamespaceContainerName = savedCurrentNamespaceContainerName ;
@@ -2872,6 +2871,30 @@ namespace ts {
28722871 /*location*/ blockLocation ,
28732872 /*multiLine*/ true
28742873 ) ;
2874+
2875+ // namespace hello.hi.world {
2876+ // function foo() {}
2877+ //
2878+ // // TODO, blah
2879+ // }
2880+ //
2881+ // should be emitted as
2882+ //
2883+ // var hello;
2884+ // (function (hello) {
2885+ // var hi;
2886+ // (function (hi) {
2887+ // var world;
2888+ // (function (world) {
2889+ // function foo() { }
2890+ // // TODO, blah
2891+ // })(world = hi.world || (hi.world = {}));
2892+ // })(hi = hello.hi || (hello.hi = {}));
2893+ // })(hello || (hello = {}));
2894+ // so if the block is a transformed module declaration, turn off the comment emit
2895+ if ( body . kind !== SyntaxKind . ModuleBlock ) {
2896+ setNodeEmitFlags ( block , block . emitFlags | NodeEmitFlags . NoComments ) ;
2897+ }
28752898 return block ;
28762899 }
28772900
Original file line number Diff line number Diff line change 1+ //// [commentInNamespaceDeclarationWithIdentifierPathName.ts]
2+ namespace hello . hi . world
3+ {
4+ function foo ( ) { }
5+
6+ // TODO, blah
7+ }
8+
9+ //// [commentInNamespaceDeclarationWithIdentifierPathName.js]
10+ var hello ;
11+ ( function ( hello ) {
12+ var hi ;
13+ ( function ( hi ) {
14+ var world ;
15+ ( function ( world ) {
16+ function foo ( ) { }
17+ // TODO, blah
18+ } ) ( world = hi . world || ( hi . world = { } ) ) ;
19+ } ) ( hi = hello . hi || ( hello . hi = { } ) ) ;
20+ } ) ( hello || ( hello = { } ) ) ;
Original file line number Diff line number Diff line change 1+ === tests/cases/compiler/commentInNamespaceDeclarationWithIdentifierPathName.ts ===
2+ namespace hello.hi.world
3+ >hello : Symbol(hello, Decl(commentInNamespaceDeclarationWithIdentifierPathName.ts, 0, 0))
4+ >hi : Symbol(hi, Decl(commentInNamespaceDeclarationWithIdentifierPathName.ts, 0, 16))
5+ >world : Symbol(world, Decl(commentInNamespaceDeclarationWithIdentifierPathName.ts, 0, 19))
6+ {
7+ function foo() {}
8+ >foo : Symbol(foo, Decl(commentInNamespaceDeclarationWithIdentifierPathName.ts, 1, 1))
9+
10+ // TODO, blah
11+ }
Original file line number Diff line number Diff line change 1+ === tests/cases/compiler/commentInNamespaceDeclarationWithIdentifierPathName.ts ===
2+ namespace hello.hi.world
3+ >hello : typeof hello
4+ >hi : typeof hi
5+ >world : typeof world
6+ {
7+ function foo() {}
8+ >foo : () => void
9+
10+ // TODO, blah
11+ }
Original file line number Diff line number Diff line change 1+ namespace hello . hi . world
2+ {
3+ function foo ( ) { }
4+
5+ // TODO, blah
6+ }
You can’t perform that action at this time.
0 commit comments