From 8e28d05bd956d372de494f62dbbc5703c8e8c09b Mon Sep 17 00:00:00 2001 From: johnsoncodehk Date: Sun, 8 Jan 2023 19:34:35 +0800 Subject: [PATCH] fix: check failedLookupLocations close #2282 --- packages/language-server/src/common/project.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/language-server/src/common/project.ts b/packages/language-server/src/common/project.ts index 0dee3fa65..dacf8e7c8 100644 --- a/packages/language-server/src/common/project.ts +++ b/packages/language-server/src/common/project.ts @@ -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(); - 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));