@@ -1600,16 +1600,16 @@ module ts {
1600
1600
var emitLeadingCommentsOfPosition = compilerOptions . removeComments ? ( pos : number ) => { } : emitLeadingCommentsOfLocalPosition ;
1601
1601
1602
1602
var detachedCommentsInfo : { nodePos : number ; detachedCommentEndPos : number } [ ] ;
1603
+
1603
1604
/** Emit detached comments of the node */
1604
1605
var emitDetachedComments = compilerOptions . removeComments ? ( node : TextRange ) => { } : emitDetachedCommentsAtPosition ;
1605
1606
1606
- /** Emits /// or pinned which is comment starting with /*! comments */
1607
- var emitPinnedOrTripleSlashComments = compilerOptions . removeComments ? ( node : Node ) => { } : emitPinnedOrTripleSlashCommentsOfNode ;
1608
-
1609
1607
var writeComment = writeCommentRange ;
1610
1608
1611
1609
/** Emit a node */
1610
+ var emitNodeWithoutSourceMap = compilerOptions . removeComments ? emitNodeWithoutSourceMapWithoutComments : emitNodeWithoutSourceMapWithComments ;
1612
1611
var emit = emitNodeWithoutSourceMap ;
1612
+ var emitWithoutComments = emitNodeWithoutSourceMapWithoutComments ;
1613
1613
1614
1614
/** Called just before starting emit of a node */
1615
1615
10000
var emitStart = function ( node : Node ) { } ;
@@ -2061,7 +2061,7 @@ module ts {
2061
2061
sourceMapDir = getDirectoryPath ( normalizePath ( jsFilePath ) ) ;
2062
2062
}
2063
2063
2064
- function emitNodeWithMap ( node : Node ) {
2064
+ function emitNodeWithSourceMap ( node : Node ) {
2065
2065
if ( node ) {
2066
2066
if ( node . kind != SyntaxKind . SourceFile ) {
2067
2067
recordEmitNodeStartSpan ( node ) ;
@@ -2075,8 +2075,17 @@ module ts {
2075
2075
}
2076
2076
}
2077
2077
2078
+ function emitNodeWithSourceMapWithoutComments ( node : Node ) {
2079
+ if ( node ) {
2080
+ recordEmitNodeStartSpan ( node ) ;
2081
+ emitNodeWithoutSourceMapWithoutComments ( node ) ;
2082
+ recordEmitNodeEndSpan ( node ) ;
2083
+ }
2084
+ }
2085
+
2078
2086
writeEmittedFiles = writeJavaScriptAndSourceMapFile ;
2079
- emit = emitNodeWithMap ;
2087
+ emit = emitNodeWithSourceMap ;
2088
+ emitWithoutComments = emitNodeWithSourceMapWithoutComments ;
2080
2089
emitStart = recordEmitNodeStartSpan ;
2081
2090
emitEnd = recordEmitNodeEndSpan ;
2082
2091
emitToken = writeTextWithSpanRecord ;
@@ -4273,7 +4282,7 @@ module ts {
4273
4282
4274
4283
// Don't emit comments on this body. We'll have already taken care of it above
4275
4284
// when we called emitDetachedComments.
4276
- emitNodeWithoutSourceMap ( body , /*disableComments:*/ true ) ;
4285
+ emitWithoutComments ( body ) ;
4277
4286
emitEnd ( body ) ;
4278
4287
write ( ";" ) ;
4279
4288
emitTempDeclarations ( /*newLine*/ false ) ;
@@ -4284,7 +4293,10 @@ module ts {
4284
4293
writeLine ( ) ;
4285
4294
emitLeadingComments ( node . body ) ;
4286
4295
write ( "return " ) ;
4287
- emit ( node . body , /*disableComments:*/ true ) ;
4296
+
4297
+ // Don't emit comments on this body. We'll have already taken care of it above
4298
+ // when we called emitDetachedComments.
4299
+ emitWithoutComments ( node . body ) ;
4288
4300
write ( ";" ) ;
4289
4301
emitTrailingComments ( node . body ) ;
4290
4302
@@ -5146,7 +5158,7 @@ module ts {
5146
5158
emitLeadingComments ( node . endOfFileToken ) ;
5147
5159
}
5148
5160
5149
- function emitNodeWithoutSourceMap ( node : Node , disableComments ?: boolean ) : void {
5161
+ function emitNodeWithoutSourceMapWithComments ( node : Node ) : void {
5150
5162
if ( ! node ) {
5151
5163
return ;
5152
5164
}
@@ -5155,7 +5167,7 @@ module ts {
5155
5167
return emitPinnedOrTripleSlashComments ( node ) ;
5156
5168
}
5157
5169
5158
- var emitComments = ! disableComments && shouldEmitLeadingAndTrailingComments ( node ) ;
5170
+ var emitComments = shouldEmitLeadingAndTrailingComments ( node ) ;
5159
5171
if ( emitComments ) {
5160
5172
emitLeadingComments ( node ) ;
5161
5173
}
@@ -5167,6 +5179,18 @@ module ts {
5167
5179
}
5168
5180
}
5169
5181
5182
+ function emitNodeWithoutSourceMapWithoutComments ( node : Node ) : void {
5183
+ if ( ! node ) {
5184
+ return ;
5185
+ }
5186
+
5187
+ if ( node . flags & NodeFlags . Ambient ) {
5188
+ return emitPinnedOrTripleSlashComments ( node ) ;
5189
+ }
5190
+
5191
+ emitJavaScriptWorker ( node ) ;
5192
+ }
5193
+
5170
5194
function shouldEmitLeadingAndTrailingComments ( node : Node ) {
5171
5195
switch ( node . kind ) {
5172
5196
// All of these entities are emitted in a specialized fashion. As such, we allow
@@ -5461,7 +5485,8 @@ module ts {
5461
5485
}
5462
5486
}
5463
5487
5464
- function emitPinnedOrTripleSlashCommentsOfNode ( node : Node ) {
5488
+ /** Emits /// or pinned which is comment starting with /*! comments */
5489
+ function emitPinnedOrTripleSlashComments ( node : Node ) {
5465
5490
var pinnedComments = ts . filter ( getLeadingCommentsToEmit ( node ) , isPinnedOrTripleSlashComment ) ;
5466
5491
5467
5492
function isPinnedOrTripleSlashComment ( comment : CommentRange ) {
0 commit comments