From 892d6cc99749247884fdbe2d89ca13def3af8bdb Mon Sep 17 00:00:00 2001 From: Kitson Kelly Date: Wed, 16 Dec 2020 06:34:39 +1100 Subject: refactor(lsp): optimise static assets (#8771) Fixes #8158 --- cli/tsc/99_main_compiler.js | 10 ++++++++++ cli/tsc/compiler.d.ts | 6 ++++++ 2 files changed, 16 insertions(+) (limited to 'cli/tsc') diff --git a/cli/tsc/99_main_compiler.js b/cli/tsc/99_main_compiler.js index a78b85203..0be0fdc2c 100644 --- a/cli/tsc/99_main_compiler.js +++ b/cli/tsc/99_main_compiler.js @@ -487,6 +487,16 @@ delete Object.prototype.__proto__; compilationSettings = options; return respond(id, true); } + case "getAsset": { + const sourceFile = host.getSourceFile( + request.specifier, + ts.ScriptTarget.ESNext, + ); + return core.jsonOpSync( + "op_set_asset", + { text: sourceFile && sourceFile.text }, + ); + } case "getSemanticDiagnostics": { const diagnostics = languageService.getSemanticDiagnostics( request.specifier, diff --git a/cli/tsc/compiler.d.ts b/cli/tsc/compiler.d.ts index a1f4e851c..39afbe884 100644 --- a/cli/tsc/compiler.d.ts +++ b/cli/tsc/compiler.d.ts @@ -42,6 +42,7 @@ declare global { type LanguageServerRequest = | ConfigureRequest + | GetAsset | GetSyntacticDiagnosticsRequest | GetSemanticDiagnosticsRequest | GetSuggestionDiagnosticsRequest @@ -62,6 +63,11 @@ declare global { compilerOptions: Record; } + interface GetAsset extends BaseLanguageServerRequest { + method: "getAsset"; + specifier: string; + } + interface GetSyntacticDiagnosticsRequest extends BaseLanguageServerRequest { method: "getSyntacticDiagnostics"; specifier: string; -- cgit v1.2.3