Merge pull request #4482 from jakebailey/emit-file-diagnostics

Call clearFiles on internal EmitOutput diagnostics, pass args down
pull/4556/head v0.50.0-dev-20240531
Henning Dieterichs 8 months ago committed by GitHub
commit c49fdf9f0c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -216,9 +216,10 @@ export interface DiagnosticRelatedInformation {
messageText: string | DiagnosticMessageChain; messageText: string | DiagnosticMessageChain;
} }
interface EmitOutput { export interface EmitOutput {
outputFiles: OutputFile[]; outputFiles: OutputFile[];
emitSkipped: boolean; emitSkipped: boolean;
diagnostics?: Diagnostic[];
} }
interface OutputFile { interface OutputFile {
name: string; name: string;
@ -521,7 +522,11 @@ export interface TypeScriptWorker {
* Get transpiled output for the given file. * Get transpiled output for the given file.
* @returns `typescript.EmitOutput` * @returns `typescript.EmitOutput`
*/ */
getEmitOutput(fileName: string): Promise<EmitOutput>; getEmitOutput(
fileName: string,
emitOnlyDtsFiles?: boolean,
forceDtsEmit?: boolean
): Promise<EmitOutput>;
/** /**
* Get possible code fixes at the given position in the file. * Get possible code fixes at the given position in the file.

@ -8,6 +8,7 @@ import { libFileMap } from './lib/lib';
import { import {
Diagnostic, Diagnostic,
DiagnosticRelatedInformation, DiagnosticRelatedInformation,
EmitOutput,
IExtraLibs, IExtraLibs,
TypeScriptWorker as ITypeScriptWorker TypeScriptWorker as ITypeScriptWorker
} from './monaco.contribution'; } from './monaco.contribution';
@ -401,11 +402,26 @@ export class TypeScriptWorker implements ts.LanguageServiceHost, ITypeScriptWork
return this._languageService.getRenameInfo(fileName, position, options); return this._languageService.getRenameInfo(fileName, position, options);
} }
async getEmitOutput(fileName: string): Promise<ts.EmitOutput> { async getEmitOutput(
fileName: string,
emitOnlyDtsFiles?: boolean,
forceDtsEmit?: boolean
): Promise<EmitOutput> {
if (fileNameIsLib(fileName)) { if (fileNameIsLib(fileName)) {
return { outputFiles: [], emitSkipped: true }; 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,
emitOnlyDtsFiles,
forceDtsEmit
) as ts.EmitOutput & {
diagnostics?: ts.Diagnostic[];
};
const diagnostics = emitOutput.diagnostics
? TypeScriptWorker.clearFiles(emitOutput.diagnostics)
: undefined;
return { ...emitOutput, diagnostics };
} }
async getCodeFixesAtPosition( async getCodeFixesAtPosition(

Loading…
Cancel
Save