Skip to content

Commit

Permalink
fix: cannot resolve compilerOptions.types
Browse files Browse the repository at this point in the history
close #1650
  • Loading branch information
johnsoncodehk committed Aug 6, 2022
1 parent eb8d194 commit f1dc5bd
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions packages/vue-language-server/src/projects.ts
Expand Up @@ -32,22 +32,22 @@ export function createProjects(
uri: string,
time: number,
} | undefined;
const fileExistsCache = shared.createPathMap<boolean>();
const directoryExistsCache = shared.createPathMap<boolean>();
const fileExistsCache = new Map<string, boolean>();
const directoryExistsCache = new Map<string, boolean>();
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;
Expand Down Expand Up @@ -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[] = [];
Expand Down

0 comments on commit f1dc5bd

Please sign in to comment.