@@ -879,7 +879,7 @@ namespace ts {
879
879
let containerEnd = - 1 ;
880
880
let declarationListContainerEnd = - 1 ;
881
881
let currentLineMap : readonly number [ ] | undefined ;
882
- let detachedCommentsInfo : { nodePos : number , detachedCommentEndPos : number } [ ] | undefined ;
882
+ let detachedCommentsInfo : { nodePos : number , detachedCommentEndPos : number } [ ] | undefined ;
883
883
let hasWrittenComment = false ;
884
884
let commentsDisabled = ! ! printerOptions . removeComments ;
885
885
let lastNode : Node | undefined ;
@@ -902,6 +902,11 @@ namespace ts {
902
902
bundleFileInfo
903
903
} ;
904
904
905
+ function getPreserveSourceNewlines ( node : Node ) {
906
+ // Ignore preserveSourceNewlines if it has enabled the flag.
907
+ return preserveSourceNewlines && ! ( getEmitFlags ( node ) & EmitFlags . IgnoreSourceNewlines ) ;
908
+ }
909
+
905
910
function printNode ( hint : EmitHint , node : Node , sourceFile : SourceFile ) : string {
906
911
switch ( hint ) {
907
912
case EmitHint . SourceFile :
@@ -1205,25 +1210,25 @@ namespace ts {
1205
1210
if ( onEmitNode !== noEmitNotification && ( ! isEmitNotificationEnabled || isEmitNotificationEnabled ( node ) ) ) {
1206
1211
return pipelineEmitWithNotification ;
1207
1212
}
1208
- // falls through
1213
+ // falls through
1209
1214
1210
1215
case PipelinePhase . Substitution :
1211
1216
if ( substituteNode !== noEmitSubstitution && ( lastSubstitution = substituteNode ( emitHint , node ) ) !== node ) {
1212
1217
return pipelineEmitWithSubstitution ;
1213
1218
}
1214
- // falls through
1219
+ // falls through
1215
1220
1216
1221
case PipelinePhase . Comments :
1217
1222
if ( ! commentsDisabled && node . kind !== SyntaxKind . SourceFile ) {
1218
1223
return pipelineEmitWithComments ;
1219
1224
}
1220
- // falls through
1225
+ // falls through
1221
1226
1222
1227
case PipelinePhase . SourceMaps :
1223
1228
if ( ! sourceMapsDisabled && node . kind !== SyntaxKind . SourceFile && ! isInJsonFile ( node ) ) {
1224
1229
return pipelineEmitWithSourceMap ;
1225
1230
}
1226
- // falls through
1231
+ // falls through
1227
1232
1228
1233
case PipelinePhase . Emit :
1229
1234
return pipelineEmitWithHint ;
@@ -4421,7 +4426,7 @@ namespace ts {
4421
4426
return 0 ;
4422
4427
}
4423
4428
else if ( ! nodeIsSynthesized ( previousNode ) && ! nodeIsSynthesized ( nextNode ) && previousNode . parent === nextNode . parent ) {
4424
- if ( preserveSourceNewlines ) {
4429
+ if ( getPreserveSourceNewlines ( nextNode ) ) {
4425
4430
return getEffectiveLines (
4426
4431
includeComments => getLinesBetweenRangeEndAndRangeStart (
4427
4432
previousNode ,
@@ -4591,7 +4596,7 @@ namespace ts {
4591
4596
const text = isNumericLiteral ( textSourceNode ) ? textSourceNode . text : getTextOfNode ( textSourceNode ) ;
4592
4597
return jsxAttributeEscape ? `"${ escapeJsxAttributeString ( text ) } "` :
4593
4598
neverAsciiEscape || ( getEmitFlags ( node ) & EmitFlags . NoAsciiEscaping ) ? `"${ escapeString ( text ) } "` :
4594
- `"${ escapeNonAsciiString ( text ) } "` ;
4599
+ `"${ escapeNonAsciiString ( text ) } "` ;
4595
4600
}
4596
4601
else {
4597
4602
return getLiteralTextOfNode ( textSourceNode , neverAsciiEscape , jsxAttributeEscape ) ;
0 commit comments