@@ -213,7 +213,7 @@ namespace ts {
213213 emitLeadingCommentsOfPosition,
214214 } = comments ;
215215
216- let currentSourceFile : SourceFile ;
216+ let currentSourceFile : SourceFile | undefined ;
217217 let nodeIdToGeneratedName : string [ ] ; // Map of generated names for specific nodes.
218218 let autoGeneratedIdToGeneratedName : string [ ] ; // Map of generated names for temp and loop variables.
219219 let generatedNames : Map < string > ; // Set of names generated by the NameGenerator.
@@ -235,7 +235,7 @@ namespace ts {
235235 writeBundle
236236 } ;
237237
238- function printNode ( hint : EmitHint , node : Node , sourceFile : SourceFile ) : string {
238+ function printNode ( hint : EmitHint , node : Node , sourceFile : SourceFile | undefined ) : string {
239239 switch ( hint ) {
240240 case EmitHint . SourceFile :
241241 Debug . assert ( isSourceFile ( node ) , "Expected a SourceFile node." ) ;
@@ -265,7 +265,7 @@ namespace ts {
265265 return endPrint ( ) ;
266266 }
267267
268- function writeNode ( hint : EmitHint , node : Node , sourceFile : SourceFile , output : EmitTextWriter ) {
268+ function writeNode ( hint : EmitHint , node : Node , sourceFile : SourceFile | undefined , output : EmitTextWriter ) {
269269 const previousWriter = writer ;
270270 setWriter ( output ) ;
271271 print ( hint , node , sourceFile ) ;
@@ -302,8 +302,10 @@ namespace ts {
302302 return text ;
303303 }
304304
305- function print ( hint : EmitHint , node : Node , sourceFile : SourceFile ) {
306- setSourceFile ( sourceFile ) ;
305+ function print ( hint : EmitHint , node : Node , sourceFile : SourceFile | undefined ) {
306+ if ( sourceFile ) {
307+ setSourceFile ( sourceFile ) ;
308+ }
307309 pipelineEmitWithNotification ( hint , node ) ;
308310 }
309311
@@ -1101,7 +1103,7 @@ namespace ts {
11011103 function emitPropertyAccessExpression ( node : PropertyAccessExpression ) {
11021104 let indentBeforeDot = false ;
11031105 let indentAfterDot = false ;
1104- if ( ! ( getEmitFlags ( node ) & EmitFlags . NoIndentation ) ) {
1106+ if ( currentSourceFile && ! ( getEmitFlags ( node ) & EmitFlags . NoIndentation ) ) {
11051107 const dotRangeStart = node . expression . end ;
11061108 const dotRangeEnd = skipTrivia ( currentSourceFile . text , node . expression . end ) + 1 ;
11071109 const dotToken = < Node > { kind : SyntaxKind . DotToken , pos : dotRangeStart , end : dotRangeEnd } ;
@@ -2461,7 +2463,7 @@ namespace ts {
24612463
24622464 const firstChild = children [ 0 ] ;
24632465 if ( firstChild === undefined ) {
2464- return ! rangeIsOnSingleLine ( parentNode , currentSourceFile ) ;
2466+ return ! ( currentSourceFile && rangeIsOnSingleLine ( parentNode , currentSourceFile ) ) ;
24652467 }
24662468 else if ( positionIsSynthesized ( parentNode . pos ) || nodeIsSynthesized ( firstChild ) ) {
24672469 return synthesizedNodeStartsOnNewLine ( firstChild , format ) ;
@@ -2487,7 +2489,7 @@ namespace ts {
24872489 return synthesizedNodeStartsOnNewLine ( previousNode , format ) || synthesizedNodeStartsOnNewLine ( nextNode , format ) ;
24882490 }
24892491 else {
2490- return ! rangeEndIsOnSameLineAsRangeStart ( previousNode , nextNode , currentSourceFile ) ;
2492+ return ! ( currentSourceFile && rangeEndIsOnSameLineAsRangeStart ( previousNode , nextNode , currentSourceFile ) ) ;
24912493 }
24922494 }
24932495 else {
@@ -2506,13 +2508,13 @@ namespace ts {
25062508
25072509 const lastChild = lastOrUndefined ( children ) ;
25082510 if ( lastChild === undefined ) {
2509- return ! rangeIsOnSingleLine ( parentNode , currentSourceFile ) ;
2511+ return ! ( currentSourceFile && rangeIsOnSingleLine ( parentNode , currentSourceFile ) ) ;
25102512 }
25112513 else if ( positionIsSynthesized ( parentNode . pos ) || nodeIsSynthesized ( lastChild ) ) {
25122514 return synthesizedNodeStartsOnNewLine ( lastChild , format ) ;
25132515 }
25142516 else {
2515- return ! rangeEndPositionsAreOnSameLine ( parentNode , lastChild , currentSourceFile ) ;
2517+ return ! ( currentSourceFile && rangeEndPositionsAreOnSameLine ( parentNode , lastChild , currentSourceFile ) ) ;
25162518 }
25172519 }
25182520 else {
@@ -2901,7 +2903,7 @@ namespace ts {
29012903 // Precomputed Formats
29022904 Modifiers = SingleLine | SpaceBetweenSiblings ,
29032905 HeritageClauses = SingleLine | SpaceBetweenSiblings ,
2904- TypeLiteralMembers = MultiLine | Indented ,
2906+ TypeLiteralMembers = SpaceBetweenBraces | SpaceBetweenSiblings | Indented , // MultiLine | Indented,
29052907 TupleTypeElements = CommaDelimited | SpaceBetweenSiblings | SingleLine | Indented ,
29062908 UnionTypeConstituents = BarDelimited | SpaceBetweenSiblings | SingleLine ,
29072909 IntersectionTypeConstituents = AmpersandDelimited | SpaceBetweenSiblings | SingleLine ,
0 commit comments