mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 19:42:56 +01:00
Ensure types stay in sync (check that the API is implemented)
This commit is contained in:
parent
6a5f2c1d98
commit
3b7054deed
4 changed files with 25 additions and 28 deletions
|
|
@ -20,7 +20,7 @@ const ES6_LIB = {
|
|||
CONTENTS: lib_es6_dts
|
||||
};
|
||||
|
||||
export class TypeScriptWorker implements ts.LanguageServiceHost {
|
||||
export class TypeScriptWorker implements ts.LanguageServiceHost, monaco.languages.typescript.TypeScriptWorker {
|
||||
|
||||
// --- model sync -----------------------
|
||||
|
||||
|
|
@ -123,7 +123,7 @@ export class TypeScriptWorker implements ts.LanguageServiceHost {
|
|||
|
||||
// --- language features
|
||||
|
||||
private static clearFiles(diagnostics: ts.Diagnostic[]) {
|
||||
private static clearFiles(diagnostics: ts.Diagnostic[]): monaco.languages.typescript.Diagnostic[] {
|
||||
// Clear the `file` field, which cannot be JSON'yfied because it
|
||||
// contains cyclic data structures.
|
||||
diagnostics.forEach(diag => {
|
||||
|
|
@ -133,30 +133,27 @@ export class TypeScriptWorker implements ts.LanguageServiceHost {
|
|||
related.forEach(diag2 => diag2.file = undefined);
|
||||
}
|
||||
});
|
||||
return <monaco.languages.typescript.Diagnostic[]>diagnostics;
|
||||
}
|
||||
|
||||
getSyntacticDiagnostics(fileName: string): Promise<ts.Diagnostic[]> {
|
||||
getSyntacticDiagnostics(fileName: string): Promise<monaco.languages.typescript.Diagnostic[]> {
|
||||
const diagnostics = this._languageService.getSyntacticDiagnostics(fileName);
|
||||
TypeScriptWorker.clearFiles(diagnostics);
|
||||
return Promise.resolve(diagnostics);
|
||||
return Promise.resolve(TypeScriptWorker.clearFiles(diagnostics));
|
||||
}
|
||||
|
||||
getSemanticDiagnostics(fileName: string): Promise<ts.Diagnostic[]> {
|
||||
getSemanticDiagnostics(fileName: string): Promise<monaco.languages.typescript.Diagnostic[]> {
|
||||
const diagnostics = this._languageService.getSemanticDiagnostics(fileName);
|
||||
TypeScriptWorker.clearFiles(diagnostics);
|
||||
return Promise.resolve(diagnostics);
|
||||
return Promise.resolve(TypeScriptWorker.clearFiles(diagnostics));
|
||||
}
|
||||
|
||||
getSuggestionDiagnostics(fileName: string): Promise<ts.DiagnosticWithLocation[]> {
|
||||
getSuggestionDiagnostics(fileName: string): Promise<monaco.languages.typescript.Diagnostic[]> {
|
||||
const diagnostics = this._languageService.getSuggestionDiagnostics(fileName);
|
||||
TypeScriptWorker.clearFiles(diagnostics);
|
||||
return Promise.resolve(diagnostics);
|
||||
return Promise.resolve(TypeScriptWorker.clearFiles(diagnostics));
|
||||
}
|
||||
|
||||
getCompilerOptionsDiagnostics(fileName: string): Promise<ts.Diagnostic[]> {
|
||||
getCompilerOptionsDiagnostics(fileName: string): Promise<monaco.languages.typescript.Diagnostic[]> {
|
||||
const diagnostics = this._languageService.getCompilerOptionsDiagnostics();
|
||||
TypeScriptWorker.clearFiles(diagnostics);
|
||||
return Promise.resolve(diagnostics);
|
||||
return Promise.resolve(TypeScriptWorker.clearFiles(diagnostics));
|
||||
}
|
||||
|
||||
getCompletionsAtPosition(fileName: string, position: number): Promise<ts.CompletionInfo | undefined> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue