File tree Expand file tree Collapse file tree 5 files changed +72
-1
lines changed
src/compiler/transformers Expand file tree Collapse file tree 5 files changed +72
-1
lines changed Original file line number Diff line number Diff line change @@ -2859,7 +2859,6 @@ namespace ts {
2859
2859
const moduleBlock = < ModuleBlock > getInnerMostModuleDeclarationFromDottedModule ( node ) . body ;
2860
2860
statementsLocation = moveRangePos ( moduleBlock . statements , - 1 ) ;
2861
2861
}
2862
-
2863
2862
addRange ( statements , endLexicalEnvironment ( ) ) ;
2864
2863
2865
2864
currentNamespaceContainerName = savedCurrentNamespaceContainerName ;
@@ -2872,6 +2871,30 @@ namespace ts {
2872
2871
/*location*/ blockLocation ,
2873
2872
/*multiLine*/ true
2874
2873
) ;
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
+ }
2875
2898
return block ;
2876
2899
}
2877
2900
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