Skip to content

Commit 4afb9cc

Browse files
committed
Add trailing directory separators
1 parent f51e232 commit 4afb9cc

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/compiler/moduleSpecifiers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ namespace ts.moduleSpecifiers {
290290

291291
const symlinkedDirectories = links.getSymlinkedDirectoriesByRealpath();
292292
const result = symlinkedDirectories && forEachAncestorDirectory(getDirectoryPath(importedPath), realPathDirectory => {
293-
const symlinkDirectories = symlinkedDirectories.get(realPathDirectory);
293+
const symlinkDirectories = symlinkedDirectories.get(ensureTrailingDirectorySeparator(realPathDirectory));
294294
if (!symlinkDirectories) return undefined; // Continue to ancestor directory
295295

296296
// Don't want to a package to globally import from itself (importNameCodeFix_symlink_own_package.ts)

src/compiler/utilities.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -6091,9 +6091,9 @@ namespace ts {
60916091
}
60926092

60936093
export interface SymlinkCache {
6094-
/** Gets a map from symlink to realpath */
6094+
/** Gets a map from symlink to realpath. Keys have trailing directory separators. */
60956095
getSymlinkedDirectories(): ReadonlyESMap<Path, SymlinkedDirectory | false> | undefined;
6096-
/** Gets a map from realpath to symlinks */
6096+
/** Gets a map from realpath to symlinks. Keys have trailing directory separators. */
60976097
getSymlinkedDirectoriesByRealpath(): MultiMap<Path, Path> | undefined;
60986098
/** Gets a map from symlink to realpath */
60996099
getSymlinkedFiles(): ReadonlyESMap<Path, string> | undefined;
@@ -6115,8 +6115,9 @@ namespace ts {
61156115
// where both the realpath and the symlink path are inside node_modules/.pnpm. Since
61166116
// this path is never a candidate for a module specifier, we can ignore it entirely.
61176117
if (!pathContainsPnpmDirectory(symlinkPath)) {
6118+
symlinkPath = ensureTrailingDirectorySeparator(symlinkPath);
61186119
if (directory !== false && !symlinkedDirectories?.has(symlinkPath)) {
6119-
(symlinkedDirectoriesByRealpath ||= createMultiMap()).add(directory.realPath, symlinkPath)
6120+
(symlinkedDirectoriesByRealpath ||= createMultiMap()).add(ensureTrailingDirectorySeparator(directory.realPath), symlinkPath);
61206121
}
61216122
(symlinkedDirectories || (symlinkedDirectories = new Map())).set(symlinkPath, directory);
61226123
}
@@ -6133,7 +6134,7 @@ namespace ts {
61336134
const [commonResolved, commonOriginal] = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName) || emptyArray;
61346135
if (commonResolved && commonOriginal) {
61356136
cache.setSymlinkedDirectory(
6136-
toPath(commonOriginal, cwd, getCanonicalFileName),
6137+
ensureTrailingDirectorySeparator(toPath(commonOriginal, cwd, getCanonicalFileName)),
61376138
{ real: commonResolved, realPath: toPath(commonResolved, cwd, getCanonicalFileName) });
61386139
}
61396140
}

0 commit comments

Comments
 (0)