@@ -231,6 +231,7 @@ namespace ts {
231231 isValidBraceCompletionAtPosition ( fileName : string , position : number , openingBrace : number ) : string ;
232232
233233 getEmitOutput ( fileName : string ) : string ;
234+ getEmitOutputObject ( fileName : string ) : EmitOutput ;
234235 }
235236
236237 export interface ClassifierShim extends Shim {
@@ -518,9 +519,13 @@ namespace ts {
518519 }
519520
520521 function forwardJSONCall ( logger : Logger , actionDescription : string , action : ( ) => any , logPerformance : boolean ) : string {
522+ return < string > forwardCall ( logger , actionDescription , /*returnJson*/ true , action , logPerformance ) ;
523+ }
524+
525+ function forwardCall < T > ( logger : Logger , actionDescription : string , returnJson : boolean , action : ( ) => T , logPerformance : boolean ) : T | string {
521526 try {
522527 const result = simpleForwardCall ( logger , actionDescription , action , logPerformance ) ;
523- return JSON . stringify ( { result } ) ;
528+ return returnJson ? JSON . stringify ( { result } ) : result ;
524529 }
525530 catch ( err ) {
526531 if ( err instanceof OperationCanceledException ) {
@@ -532,6 +537,7 @@ namespace ts {
532537 }
533538 }
534539
540+
535541 class ShimBase implements Shim {
536542 constructor ( private factory : ShimFactory ) {
537543 factory . registerShim ( this ) ;
@@ -918,6 +924,15 @@ namespace ts {
918924 ( ) => this . languageService . getEmitOutput ( fileName )
919925 ) ;
920926 }
927+
928+ public getEmitOutputObject ( fileName : string ) : any {
929+ return forwardCall (
930+ this . logger ,
931+ `getEmitOutput('${ fileName } ')` ,
932+ /*returnJson*/ false ,
933+ ( ) => this . languageService . getEmitOutput ( fileName ) ,
934+ this . logPerformance ) ;
935+ }
921936 }
922937
923938 function convertClassifications ( classifications : Classifications ) : { spans : string , endOfLineState : EndOfLineState } {
0 commit comments