@@ -1440,29 +1440,18 @@ namespace ts {
14401440 //
14411441
14421442 function emitBlock ( node : Block ) {
1443- if ( isSingleLineEmptyBlock ( node ) ) {
1444- writeToken ( SyntaxKind . OpenBraceToken , node . pos , /*contextNode*/ node ) ;
1445- write ( " " ) ;
1446- writeToken ( SyntaxKind . CloseBraceToken , node . statements . end , /*contextNode*/ node ) ;
1447- }
1448- else {
1449- writeToken ( SyntaxKind . OpenBraceToken , node . pos , /*contextNode*/ node ) ;
1450- emitBlockStatements ( node ) ;
1451- // We have to call emitLeadingComments explicitly here because otherwise leading comments of the close brace token will not be emitted
1452- increaseIndent ( ) ;
1453- emitLeadingCommentsOfPosition ( node . statements . end ) ;
1454- decreaseIndent ( ) ;
1455- writeToken ( SyntaxKind . CloseBraceToken , node . statements . end , /*contextNode*/ node ) ;
1456- }
1443+ writeToken ( SyntaxKind . OpenBraceToken , node . pos , /*contextNode*/ node ) ;
1444+ emitBlockStatements ( node , /*forceSingleLine*/ ! node . multiLine && isEmptyBlock ( node ) ) ;
1445+ // We have to call emitLeadingComments explicitly here because otherwise leading comments of the close brace token will not be emitted
1446+ increaseIndent ( ) ;
1447+ emitLeadingCommentsOfPosition ( node . statements . end ) ;
1448+ decreaseIndent ( ) ;
1449+ writeToken ( SyntaxKind . CloseBraceToken , node . statements . end , /*contextNode*/ node ) ;
14571450 }
14581451
1459- function emitBlockStatements ( node : BlockLike ) {
1460- if ( getEmitFlags ( node ) & EmitFlags . SingleLine ) {
1461- emitList ( node , node . statements , ListFormat . SingleLineBlockStatements ) ;
1462- }
1463- else {
1464- emitList ( node , node . statements , ListFormat . MultiLineBlockStatements ) ;
1465- }
1452+ function emitBlockStatements ( node : BlockLike , forceSingleLine : boolean ) {
1453+ const format = forceSingleLine || getEmitFlags ( node ) & EmitFlags . SingleLine ? ListFormat . SingleLineBlockStatements : ListFormat . MultiLineBlockStatements ;
1454+ emitList ( node , node . statements , format ) ;
14661455 }
14671456
14681457 function emitVariableStatement ( node : VariableStatement ) {
@@ -1889,16 +1878,11 @@ namespace ts {
18891878 }
18901879
18911880 function emitModuleBlock ( node : ModuleBlock ) {
1892- if ( isEmptyBlock ( node ) ) {
1893- write ( "{ }" ) ;
1894- }
1895- else {
1896- pushNameGenerationScope ( ) ;
1897- write ( "{" ) ;
1898- emitBlockStatements ( node ) ;
1899- write ( "}" ) ;
1900- popNameGenerationScope ( ) ;
1901- }
1881+ pushNameGenerationScope ( ) ;
1882+ write ( "{" ) ;
1883+ emitBlockStatements ( node , /*forceSingleLine*/ isEmptyBlock ( node ) ) ;
1884+ write ( "}" ) ;
1885+ popNameGenerationScope ( ) ;
19021886 }
19031887
19041888 function emitCaseBlock ( node : CaseBlock ) {
@@ -2762,11 +2746,6 @@ namespace ts {
27622746 && ! rangeEndIsOnSameLineAsRangeStart ( node1 , node2 , currentSourceFile ) ;
27632747 }
27642748
2765- function isSingleLineEmptyBlock ( block : Block ) {
2766- return ! block . multiLine
2767- && isEmptyBlock ( block ) ;
2768- }
2769-
27702749 function isEmptyBlock ( block : BlockLike ) {
27712750 return block . statements . length === 0
27722751 && rangeEndIsOnSameLineAsRangeStart ( block , block , currentSourceFile ) ;
0 commit comments