From f1dc5bdd1fc482ff0f0f664dbc6a9cb10a5e44cb Mon Sep 17 00:00:00 2001 From: johnsoncodehk Date: Sat, 6 Aug 2022 16:49:23 +0800 Subject: [PATCH] fix: cannot resolve `compilerOptions.types` close #1650 --- packages/vue-language-server/src/projects.ts | 26 +++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/packages/vue-language-server/src/projects.ts b/packages/vue-language-server/src/projects.ts index ab8617d9a..de68c219a 100644 --- a/packages/vue-language-server/src/projects.ts +++ b/packages/vue-language-server/src/projects.ts @@ -32,22 +32,22 @@ export function createProjects( uri: string, time: number, } | undefined; - const fileExistsCache = shared.createPathMap(); - const directoryExistsCache = shared.createPathMap(); + const fileExistsCache = new Map(); + const directoryExistsCache = new Map(); const sys: ts.System = capabilities.workspace?.didChangeWatchedFiles // don't cache fs result if client not supports file watcher ? { ...ts.sys, fileExists(path: string) { - if (!fileExistsCache.fsPathHas(path)) { - fileExistsCache.fsPathSet(path, ts.sys.fileExists(path)); + if (!fileExistsCache.has(path)) { + fileExistsCache.set(path, ts.sys.fileExists(path)); } - return fileExistsCache.fsPathGet(path)!; + return fileExistsCache.get(path)!; }, directoryExists(path: string) { - if (!directoryExistsCache.fsPathHas(path)) { - directoryExistsCache.fsPathSet(path, ts.sys.directoryExists(path)); + if (!directoryExistsCache.has(path)) { + directoryExistsCache.set(path, ts.sys.directoryExists(path)); } - return directoryExistsCache.fsPathGet(path)!; + return directoryExistsCache.get(path)!; }, } : ts.sys; @@ -123,13 +123,9 @@ export function createProjects( async function onDidChangeWatchedFiles(handler: vscode.DidChangeWatchedFilesParams) { - for (const change of handler.changes) { - if (change.type === vscode.FileChangeType.Created) { - fileExistsCache.uriSet(change.uri, true); - } - else if (change.type === vscode.FileChangeType.Deleted) { - fileExistsCache.uriSet(change.uri, false); - } + if (handler.changes.some(change => change.type === vscode.FileChangeType.Created || change.type === vscode.FileChangeType.Deleted)) { + fileExistsCache.clear(); + directoryExistsCache.clear(); } const tsConfigChanges: vscode.FileEvent[] = [];