Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2894,10 +2894,11 @@ namespace ts {
path += (i === 2 ? "/" : "-") + components[i];
i++;
}
// The strange "/fake.file" is to ensure we first resolve in node_modules for the current directory.
const localOverride = resolveModuleName("@typescript/" + path, currentDirectory + "/fake.file", { moduleResolution: ModuleResolutionKind.NodeJs }, host, moduleResolutionCache);
if (localOverride?.resolvedModule) {
return localOverride.resolvedModule.resolvedFileName;

const resolveFrom = combinePaths(currentDirectory, `/__lib_node_modules_lookup_${libFileName}__.ts`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This always ignores currentDirectory because the latter argument is absolute.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guessing this didn’t break tests only because all the tests are rooted at /

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice spot!

const localOverrideModuleResult = resolveModuleName("@typescript/" + path, resolveFrom, { moduleResolution: ModuleResolutionKind.NodeJs }, host, moduleResolutionCache);
if (localOverrideModuleResult?.resolvedModule) {
return localOverrideModuleResult.resolvedModule.resolvedFileName;
}
return combinePaths(defaultLibraryPath, libFileName);
}
Expand Down