Merge pull request #9485 from Microsoft/getEmitOutputAsObject
add new method getEmitOutputObject to return result of the emit as object
This commit is contained in:
commit
d56a50bedb
1 changed files with 16 additions and 1 deletions
|
@ -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 <string>forwardCall(logger, actionDescription, /*returnJson*/ true, action, logPerformance);
|
||||
}
|
||||
|
||||
function forwardCall<T>(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 } {
|
||||
|
|
Loading…
Reference in a new issue