Repository navigation
Conversation
Port typescript-go's `initMapperWorker` (internal/compiler/projectreferenceparser.go) so a parent tsconfig sees its references' references, not just direct ones. `references_resolved` is now populated recursively at load time, with cycle detection on canonical file paths; `resolve_tsconfig_solution` and `claims_ownership_of` walk the graph breadth-first and pick the deepest project that owns the file — mirroring `maps.Copy`'s child-wins behavior in typescript-go. - New `TsconfigResolveContext::loading_references` breaks cycles by skipping a reference already mid-load (matches typescript-go's `seen` set). Direct self-reference still errors with `TsconfigSelfReference`. - `Cache::resolve_tsconfig_path` extracted from the existing dir/file/ extensionless resolution so cycle keys are canonical. - Closes the divergence called out in #1154's "Transitive references" caveat.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 05-27-refactor_tsconfig_precompute_owned_files #1164 +/- ##
==================================================================================
- Coverage 93.33% 93.31% -0.03%
==================================================================================
Files 22 22
Lines 4234 4265 +31
==================================================================================
+ Hits 3952 3980 +28
- Misses 282 285 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a18b4973ae
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let referenced_tsconfig = self.load_tsconfig( | ||
| /* root */ true, | ||
| &reference_input, | ||
| references, | ||
| ctx, | ||
| )?; | ||
| tsconfig.references_resolved.push(referenced_tsconfig); |
There was a problem hiding this comment.
Traverse transitive references during manual directory resolution
When a manual tsconfig is used with the directory-based resolve() API, this recursive load still leaves grandchildren nested under their parent, but resolve_references_then_self_paths only scans the root's direct references_resolved. In a graph like the new fixture (root -> parent -> child), resolver.resolve(child/src, "@child/foo") will never consult the child's paths and will fall back to the root config, even though resolve_file() passes because it selects the child solution first. The transitive graph needs to be traversed or flattened for this path-selection code as well.
Useful? React with 👍 / 👎.
Merging this PR will degrade performance by 4.09%
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
Summary
Port typescript-go's
initMapperWorker(internal/compiler/projectreferenceparser.go) so a parent tsconfig sees its references' references, not just direct ones. Closes the divergence called out in #1154's "Transitive references" caveat (and matched in typescript-go'sgetResolvedProjectReferenceToRedirect/isSourceOfProjectReferenceRedirectflow).Changes
references_resolvedis populated recursively at load time. The references loop now callsload_tsconfiginstead ofcache.get_tsconfigdirectly, so each reference's own references are wired up.TsconfigResolveContext::loading_referencesbreaks cycles in the reference graph (a → b → a) by skipping a tsconfig already mid-load. Mirrors typescript-go'sseenset. Direct self-references (a → a) still surface asTsconfigSelfReference.resolve_tsconfig_solutionandclaims_ownership_ofwalk the graph breadth-first and pick the deepest project that owns the file — matching typescript-go'smaps.Copy-into-deepest-wins behavior at line 99 ofprojectreferenceparser.go.Cache::resolve_tsconfig_pathextracted from the existing dir/file/extensionless resolution so cycle keys are computed on the canonicaltsconfig.jsonfile path.Test
project-references-transitive/: a 3-level chain (root → parent → child) where neitherrootnorparentowns the queried file butchilddoes (viapaths). Without transitive walking,resolve_tsconfig_solutionwould stop atparentand the@child/*alias wouldn't apply.Known limits
Cyclic references (
a → b → a) are broken, but the cached tsconfig that was mid-load when the cycle was detected has an incompletereferences_resolved. Subsequent direct loads of that tsconfig return the cached (incomplete) version. Matches typescript-go's behavior where the cyclic edge is simply dropped viaseen.AddIfAbsent.