Skip to content

Commit

Permalink
fix: check failedLookupLocations
Browse files Browse the repository at this point in the history
close #2282
  • Loading branch information
johnsoncodehk committed Jan 8, 2023
1 parent 6168c50 commit 8e28d05
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/language-server/src/common/project.ts
Expand Up @@ -322,10 +322,14 @@ function getHTMLDocumentContext(
host.getCompilationSettings(),
host,
);
const failedLookupLocations: path.PosixPath[] = (resolveResult as any).failedLookupLocations;
const failedLookupLocations: path.PosixPath[] | undefined = typeof resolveResult === 'object' ? (resolveResult as any).failedLookupLocations : [];
const dirs = new Set<string>();

for (let failed of failedLookupLocations) {
if (!failedLookupLocations) {
console.warn(`[volar] failedLookupLocations not exists, ts: ${ts.version}`);
}

for (let failed of failedLookupLocations ?? []) {
const fileName = path.basename(failed);
if (fileName === 'index.d.ts' || fileName === '*.d.ts') {
dirs.add(path.dirname(failed));
Expand Down

0 comments on commit 8e28d05

Please sign in to comment.