diff --git a/src/language/typescript/monaco.contribution.ts b/src/language/typescript/monaco.contribution.ts index 4220bcfb2e..d018902136 100644 --- a/src/language/typescript/monaco.contribution.ts +++ b/src/language/typescript/monaco.contribution.ts @@ -216,9 +216,10 @@ export interface DiagnosticRelatedInformation { messageText: string | DiagnosticMessageChain; } -interface EmitOutput { +export interface EmitOutput { outputFiles: OutputFile[]; emitSkipped: boolean; + diagnostics?: Diagnostic[]; } interface OutputFile { name: string; diff --git a/src/language/typescript/tsWorker.ts b/src/language/typescript/tsWorker.ts index a0c7719e1e..4ffc8867dc 100644 --- a/src/language/typescript/tsWorker.ts +++ b/src/language/typescript/tsWorker.ts @@ -8,6 +8,7 @@ import { libFileMap } from './lib/lib'; import { Diagnostic, DiagnosticRelatedInformation, + EmitOutput, IExtraLibs, TypeScriptWorker as ITypeScriptWorker } from './monaco.contribution'; @@ -401,11 +402,18 @@ export class TypeScriptWorker implements ts.LanguageServiceHost, ITypeScriptWork return this._languageService.getRenameInfo(fileName, position, options); } - async getEmitOutput(fileName: string): Promise { + async getEmitOutput(fileName: string): Promise { if (fileNameIsLib(fileName)) { return { outputFiles: [], emitSkipped: true }; } - return this._languageService.getEmitOutput(fileName); + // The diagnostics property is internal, returning it without clearing breaks message serialization. + const emitOutput = this._languageService.getEmitOutput(fileName) as ts.EmitOutput & { + diagnostics?: ts.Diagnostic[]; + }; + const diagnostics = emitOutput.diagnostics + ? TypeScriptWorker.clearFiles(emitOutput.diagnostics) + : undefined; + return { ...emitOutput, diagnostics }; } async getCodeFixesAtPosition(