diff --git a/src/services/shims.ts b/src/services/shims.ts index e0f7cc6dc7694..a233f99d03fd6 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -231,6 +231,7 @@ namespace ts { isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): string; getEmitOutput(fileName: string): string; + getEmitOutputObject(fileName: string): EmitOutput; } export interface ClassifierShim extends Shim { @@ -518,9 +519,13 @@ namespace ts { } function forwardJSONCall(logger: Logger, actionDescription: string, action: () => any, logPerformance: boolean): string { + return forwardCall(logger, actionDescription, /*returnJson*/ true, action, logPerformance); + } + + function forwardCall(logger: Logger, actionDescription: string, returnJson: boolean, action: () => T, logPerformance: boolean): T | string { try { const result = simpleForwardCall(logger, actionDescription, action, logPerformance); - return JSON.stringify({ result }); + return returnJson ? JSON.stringify({ result }) : result; } catch (err) { if (err instanceof OperationCanceledException) { @@ -532,6 +537,7 @@ namespace ts { } } + class ShimBase implements Shim { constructor(private factory: ShimFactory) { factory.registerShim(this); @@ -918,6 +924,15 @@ namespace ts { () => this.languageService.getEmitOutput(fileName) ); } + + public getEmitOutputObject(fileName: string): any { + return forwardCall( + this.logger, + `getEmitOutput('${fileName}')`, + /*returnJson*/ false, + () => this.languageService.getEmitOutput(fileName), + this.logPerformance); + } } function convertClassifications(classifications: Classifications): { spans: string, endOfLineState: EndOfLineState } {