@@ -231,6 +231,7 @@ namespace ts {
231
231
isValidBraceCompletionAtPosition ( fileName : string , position : number , openingBrace : number ) : string ;
232
232
233
233
getEmitOutput ( fileName : string ) : string ;
234
+ getEmitOutputObject ( fileName : string ) : EmitOutput ;
234
235
}
235
236
236
237
export interface ClassifierShim extends Shim {
@@ -518,9 +519,13 @@ namespace ts {
518
519
}
519
520
520
521
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 {
521
526
try {
522
527
const result = simpleForwardCall ( logger , actionDescription , action , logPerformance ) ;
523
- return JSON . stringify ( { result } ) ;
528
+ return returnJson ? JSON . stringify ( { result } ) : result ;
524
529
}
525
530
catch ( err ) {
526
531
if ( err instanceof OperationCanceledException ) {
@@ -532,6 +537,7 @@ namespace ts {
532
537
}
533
538
}
534
539
540
+
535
541
class ShimBase implements Shim {
536
542
constructor ( private factory : ShimFactory ) {
537
543
factory . registerShim ( this ) ;
@@ -918,6 +924,15 @@ namespace ts {
918
924
( ) => this . languageService . getEmitOutput ( fileName )
919
925
) ;
920
926
}
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
+ }
921
936
}
922
937
923
938
function convertClassifications ( classifications : Classifications ) : { spans : string , endOfLineState : EndOfLineState } {
0 commit comments