@@ -1440,29 +1440,18 @@ namespace ts {
1440
1440
//
1441
1441
1442
1442
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 ) ;
1457
1450
}
1458
1451
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 ) ;
1466
1455
}
1467
1456
1468
1457
function emitVariableStatement ( node : VariableStatement ) {
@@ -1889,16 +1878,11 @@ namespace ts {
1889
1878
}
1890
1879
1891
1880
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 ( ) ;
1902
1886
}
1903
1887
1904
1888
function emitCaseBlock ( node : CaseBlock ) {
@@ -2762,11 +2746,6 @@ namespace ts {
2762
2746
&& ! rangeEndIsOnSameLineAsRangeStart ( node1 , node2 , currentSourceFile ) ;
2763
2747
}
2764
2748
2765
- function isSingleLineEmptyBlock ( block : Block ) {
2766
- return ! block . multiLine
2767
- && isEmptyBlock ( block ) ;
2768
- }
2769
-
2770
2749
function isEmptyBlock ( block : BlockLike ) {
2771
2750
return block . statements . length === 0
2772
2751
&& rangeEndIsOnSameLineAsRangeStart ( block , block , currentSourceFile ) ;
0 commit comments