Repository navigation
fix(module): port the directory-only candidate checks outside the type roots - #1049
Merged
camc314 merged 1 commit intoNov 20, 2026
Merged
Conversation
…e roots Go's `resolutionCandidate` has a `directoryOnly` flag for a candidate that was written with a trailing `/`, and its `path` has no trailing separator. oxc-project#1008 ported the checks at the two type root call sites. Five other functions still worked on the string with the trailing `/`: - `try_load_input_file_for_path` and `load_file_name_from_package_json_field` now return `continue_searching()` for a directory-only candidate, as Go does. Before, an `imports` target `./dist.js/` resolved to `dist.d.js/.ts` (TS6263 instead of TS2307), and `./dist/` reported TS2210 without a config file. - `load_module_from_file` and `load_module_from_file_no_implicit_extensions` add extensions to the path without the trailing `/` (Go's `candidate.path`), and pass the directory of that path to `try_adding_extensions` (Go's `candidate.Directory()`). Before, a `typesVersions` substitution `ts/*/` probed `ts/sub/.d.ts` and missed `ts/sub.d.ts`, so tsrs read `ts/sub/index.d.ts`. - `load_module_from_specific_node_modules_directory` builds its candidate with `resolution_candidate_from_directory_path`, as Go does, instead of removing one trailing separator. So `x//` resolves to `node_modules/x.d.ts`, and the trace prints the candidate with its `/`. The new `resolution_candidate_from_normalized` (Go `resolutionCandidateFromNormalized`) reads the flag and the path back from a candidate string. Tests: the regression cases `types-versions-directory-substitution`, `imports-directory-only-target`, and `node-modules-double-trailing-slash`. Expected output is from tsgo at the pinned commit. All three fail without the fix. Two of them have a `node_modules` directory, which `.gitignore` ignores, so the files are added with `git add -f`. AI assistance: written with Claude Code.
camc314
approved these changes
Nov 20, 2026
Contributor
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A module name or target that ends with
/resolved differently from tsgo:typesVersions"*": ["ts/*/"]withts/sub.d.tsandts/sub/index.d.ts: tsgo resolvespkg/subtots/sub.d.ts, and tsrs resolved it tots/sub/index.d.ts.importstarget"./dist.js/"resolved todist.d.js/.ts, where tsgo reports TS2307.import "x//"did not findnode_modules/x.d.ts.Go's
resolutionCandidatekeeps adirectoryOnlyflag and a path without the trailing/. #1008 ported its checks at the type root call sites. This PR ports the others:try_load_input_file_for_path,load_file_name_from_package_json_field,load_module_from_file, and thenode_moduleslookup.Tests: the
types-versions-directory-substitution,imports-directory-only-target, andnode-modules-double-trailing-slashregressions. All three fail without the fix.AI assistance: written with Claude Code.