Skip to content

Commit

Permalink
Utilize TSConfig paths in import diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
Matsuuu committed Nov 12, 2023
1 parent 961a960 commit 2fe9eac
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export function getImportDiagnostics(request: CustomElementsLanguageServiceReque
const { filePath, document, htmlLanguageService, projectBasePath, project } = request;
const filePathWithoutFile = getFilePathFolder(filePath);
const sourceFile = getSourceFile(filePath, undefined, project);
// Gather aliases and remove wildcards
const compilerPaths = Object.keys(project.getCompilerOptions().paths ?? new Map())
.map(alias => alias.endsWith("/*") ? alias.substring(0, alias.lastIndexOf("/*")) : alias);

if (!sourceFile) {
return [];
Expand Down Expand Up @@ -54,7 +57,12 @@ export function getImportDiagnostics(request: CustomElementsLanguageServiceReque

if (!resolvedModuleFileName || !associatedFiles.includes(resolvedModuleFileName)) {

const relativeImportPath = resolveImportPath(fullImportPath, filePathWithoutFile);
let relativeImportPath;
if (compilerPaths.includes(cemInstanceRef.packageName ?? '')) {
relativeImportPath = cemInstanceRef.packageName + "/" + definition.path;
} else {
relativeImportPath = resolveImportPath(fullImportPath, filePathWithoutFile);
}

notDefinedTags.push({
node: customElementTag,
Expand Down

0 comments on commit 2fe9eac

Please sign in to comment.