perf(lsp): use host-owned cache for auto-import completions (#21852)

This commit is contained in:
Nayeem Rahman 2024-01-08 17:05:05 +00:00 committed by GitHub
parent 43d2ecd4f0
commit ee45d5bf8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -537,6 +537,14 @@ delete Object.prototype.__proto__;
getProjectVersion() {
return ops.op_project_version();
},
// @ts-ignore Undocumented method.
getModuleSpecifierCache() {
return moduleSpecifierCache;
},
// @ts-ignore Undocumented method.
getCachedExportInfoMap() {
return exportMapCache;
},
getSourceFile(
specifier,
languageVersion,
@ -766,6 +774,12 @@ delete Object.prototype.__proto__;
},
};
// @ts-ignore Undocumented function.
const moduleSpecifierCache = ts.server.createModuleSpecifierCache(host);
// @ts-ignore Undocumented function.
const exportMapCache = ts.createCacheableExportInfoMap(host);
// override the npm install @types package diagnostics to be deno specific
ts.setLocalizedDiagnosticMessages((() => {
const nodeMessage = "Cannot find name '{0}'."; // don't offer any suggestions