Skip to content

Commit a192859

Browse files
committed
Add trailing directory separators
1 parent bd8a8a1 commit a192859

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
@@ -302,7 +302,7 @@ namespace ts.moduleSpecifiers {
302302

303303
const symlinkedDirectories = links.getSymlinkedDirectoriesByRealpath();
304304
const result = symlinkedDirectories && forEachAncestorDirectory(getDirectoryPath(importedPath), realPathDirectory => {
305-
const symlinkDirectories = symlinkedDirectories.get(realPathDirectory);
305+
const symlinkDirectories = symlinkedDirectories.get(ensureTrailingDirectorySeparator(realPathDirectory));
306306
if (!symlinkDirectories) return undefined; // Continue to ancestor directory
307307

308308
// 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
@@ -6079,9 +6079,9 @@ namespace ts {
60796079
}
60806080

60816081
export interface SymlinkCache {
6082-
/** Gets a map from symlink to realpath */
6082+
/** Gets a map from symlink to realpath. Keys have trailing directory separators. */
60836083
getSymlinkedDirectories(): ReadonlyESMap<Path, SymlinkedDirectory | false> | undefined;
6084-
/** Gets a map from realpath to symlinks */
6084+
/** Gets a map from realpath to symlinks. Keys have trailing directory separators. */
60856085
getSymlinkedDirectoriesByRealpath(): MultiMap<Path, Path> | undefined;
60866086
/** Gets a map from symlink to realpath */
60876087
getSymlinkedFiles(): ReadonlyESMap<Path, string> | undefined;
@@ -6103,8 +6103,9 @@ namespace ts {
61036103
// where both the realpath and the symlink path are inside node_modules/.pnpm. Since
61046104
// this path is never a candidate for a module specifier, we can ignore it entirely.
61056105
if (!containsIgnoredPath(symlinkPath)) {
6106+
symlinkPath = ensureTrailingDirectorySeparator(symlinkPath);
61066107
if (directory !== false && !symlinkedDirectories?.has(symlinkPath)) {
6107-
(symlinkedDirectoriesByRealpath ||= createMultiMap()).add(directory.realPath, symlinkPath)
6108+
(symlinkedDirectoriesByRealpath ||= createMultiMap()).add(ensureTrailingDirectorySeparator(directory.realPath), symlinkPath);
61086109
}
61096110
(symlinkedDirectories || (symlinkedDirectories = new Map())).set(symlinkPath, directory);
61106111
}
@@ -6121,7 +6122,7 @@ namespace ts {
61216122
const [commonResolved, commonOriginal] = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName) || emptyArray;
61226123
if (commonResolved && commonOriginal) {
61236124
cache.setSymlinkedDirectory(
6124-
toPath(commonOriginal, cwd, getCanonicalFileName),
6125+
ensureTrailingDirectorySeparator(toPath(commonOriginal, cwd, getCanonicalFileName)),
61256126
{ real: commonResolved, realPath: toPath(commonResolved, cwd, getCanonicalFileName) });
61266127
}
61276128
}

0 commit comments

Comments
 (0)