mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-27 22:39:59 -05:00
Only filter ignored paths from module specifier generation if there exists a better option (#43024)
* Only filter ignored paths from module specifier generation if there exists a better option * Nit
This commit is contained in:
@@ -282,10 +282,12 @@ namespace ts.moduleSpecifiers {
|
||||
const redirects = host.redirectTargetsMap.get(importedPath) || emptyArray;
|
||||
const importedFileNames = [...(referenceRedirect ? [referenceRedirect] : emptyArray), importedFileName, ...redirects];
|
||||
const targets = importedFileNames.map(f => getNormalizedAbsolutePath(f, cwd));
|
||||
let shouldFilterIgnoredPaths = !every(targets, containsIgnoredPath);
|
||||
|
||||
if (!preferSymlinks) {
|
||||
// Symlinks inside ignored paths are already filtered out of the symlink cache,
|
||||
// so we only need to remove them from the realpath filenames.
|
||||
const result = forEach(targets, p => !containsIgnoredPath(p) && cb(p, referenceRedirect === p));
|
||||
const result = forEach(targets, p => !(shouldFilterIgnoredPaths && containsIgnoredPath(p)) && cb(p, referenceRedirect === p));
|
||||
if (result) return result;
|
||||
}
|
||||
const links = host.getSymlinkCache
|
||||
@@ -312,12 +314,13 @@ namespace ts.moduleSpecifiers {
|
||||
for (const symlinkDirectory of symlinkDirectories) {
|
||||
const option = resolvePath(symlinkDirectory, relative);
|
||||
const result = cb(option, target === referenceRedirect);
|
||||
shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths
|
||||
if (result) return result;
|
||||
}
|
||||
});
|
||||
});
|
||||
return result || (preferSymlinks
|
||||
? forEach(targets, p => containsIgnoredPath(p) ? undefined : cb(p, p === referenceRedirect))
|
||||
? forEach(targets, p => shouldFilterIgnoredPaths && containsIgnoredPath(p) ? undefined : cb(p, p === referenceRedirect))
|
||||
: undefined);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user