@@ -927,6 +927,7 @@ export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFi
927927 inlineSourceMap : compilerOptions . inlineSourceMap ,
928928 extendedDiagnostics : compilerOptions . extendedDiagnostics ,
929929 onlyPrintJsDocStyle : true ,
930+ omitBraceSourceMapPositions : true ,
930931 writeBundleFileInfo : ! ! bundleBuildInfo ,
931932 recordInternalSection : ! ! bundleBuildInfo ,
932933 relativeToBuildInfo,
@@ -1391,6 +1392,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
13911392 } = handlers ;
13921393
13931394 var extendedDiagnostics = ! ! printerOptions . extendedDiagnostics ;
1395+ var omitBraceSourcePositions = ! ! printerOptions . omitBraceSourceMapPositions ;
13941396 var newLine = getNewLineCharacter ( printerOptions ) ;
13951397 var moduleKind = getEmitModuleKind ( printerOptions ) ;
13961398 var bundledHelpers = new Map < string , boolean > ( ) ;
@@ -3578,7 +3580,18 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
35783580 decreaseIndent ( ) ;
35793581 }
35803582 }
3581- pos = writeTokenText ( token , writer , pos ) ;
3583+
3584+ // We don't emit source positions for most tokens as it tends to be quite noisy, however
3585+ // we need to emit source positions for open and close braces so that tools like istanbul
3586+ // can map branches for code coverage. However, we still omit brace source positions when
3587+ // the output is a declaration file.
3588+ if ( ! omitBraceSourcePositions && ( token === SyntaxKind . OpenBraceToken || token === SyntaxKind . CloseBraceToken ) ) {
3589+ pos = writeToken ( token , pos , writer , contextNode ) ;
3590+ }
3591+ else {
3592+ pos = writeTokenText ( token , writer , pos ) ;
3593+ }
3594+
35823595 if ( isSimilarNode && contextNode . end !== pos ) {
35833596 const isJsxExprContext = contextNode . kind === SyntaxKind . JsxExpression ;
35843597 emitTrailingCommentsOfPosition ( pos , /*prefixSpace*/ ! isJsxExprContext , /*forceNoNewline*/ isJsxExprContext ) ;
0 commit comments