Fix package index fallback edge case, accept self-name resolution errors under ambiguous project root#3776
Merged
Merged
Conversation
jakebailey
approved these changes
May 8, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts Node-style module resolution to better match upstream TypeScript behavior around "exports": null (not blocking fallback resolution), and updates/accepts baseline differences for module self-name/imports behavior under ambiguous project roots.
Changes:
- Update
loadModuleFromSpecificNodeModulesDirectoryto treat falsyexports(notablynull) as not blocking fallback resolution. - Promote several module-resolution-related baseline diffs from
submoduleTriagedtosubmoduleAccepted, with notes aboutrootDir-based follow-ups. - Update/remove reference baselines to reflect corrected implicit index fallback behavior.
Reviewed changes
Copilot reviewed 7 out of 21 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
internal/module/resolver.go |
Adjusts exports-blocking logic to avoid treating "exports": null as blocking fallback resolution. |
testdata/submoduleTriaged.txt |
Removes the issue #3479 triage block entries now handled/accepted elsewhere. |
testdata/submoduleAccepted.txt |
Adds accepted baseline diffs for ambiguous-project-root module resolution differences, with follow-up note referencing #3775. |
testdata/baselines/reference/submoduleTriaged/compiler/nodeNextImportModeImplicitIndexResolution2.errors.txt.diff |
Removes an obsolete triaged diff now resolved by updated resolver behavior. |
testdata/baselines/reference/submoduleAccepted/compiler/nodeNextPackageSelfNameWithOutDir.errors.txt.diff |
Adds accepted baseline diff for self-name resolution under ambiguous project root. |
testdata/baselines/reference/submoduleAccepted/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt.diff |
Adds accepted baseline diff for self-name resolution under ambiguous project root (declDir variant). |
testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=node16).errors.txt.diff |
Adds accepted baseline diff for allowJs self-name resolution under ambiguous project root. |
testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=node18).errors.txt.diff |
Same as above for node18. |
testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=node20).errors.txt.diff |
Same as above for node20. |
testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=nodenext).errors.txt.diff |
Same as above for nodenext. |
testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=node16).errors.txt.diff |
Adds accepted baseline diff for imports map resolution under ambiguous project root (node16). |
testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=node18).errors.txt.diff |
Same as above for node18. |
testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=node20).errors.txt.diff |
Same as above for node20. |
testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=nodenext).errors.txt.diff |
Same as above for nodenext. |
testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).errors.txt.diff |
Adds accepted baseline diff for package exports + declaration emit under ambiguous project root (node16). |
testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).errors.txt.diff |
Same as above for node18. |
testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node20).errors.txt.diff |
Same as above for node20. |
testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).errors.txt.diff |
Same as above for nodenext. |
testdata/baselines/reference/submodule/compiler/nodeNextImportModeImplicitIndexResolution2.types.diff |
Removes an obsolete diff now aligned with the updated resolution behavior. |
testdata/baselines/reference/submodule/compiler/nodeNextImportModeImplicitIndexResolution2.types |
Updates expected type output now that the module resolves correctly. |
testdata/baselines/reference/submodule/compiler/nodeNextImportModeImplicitIndexResolution2.errors.txt |
Updates expected diagnostics now that the module resolves correctly. |
| conformance/propertyAndAccessorWithSameName.types.diff | ||
|
|
||
| ## Module resolver does not guess the project root to provide speculative resolutions for self-name | ||
| ## imports in the presence of TS2209 "ambiguous project root" errors. |
Comment on lines
1123
to
+1127
| if r.features&NodeResolutionFeaturesExports != 0 && | ||
| packageInfo.Exists() && | ||
| packageInfo.Contents.Exports.Type != packagejson.JSONValueTypeNotPresent { | ||
| // package exports are higher priority than file/directory/typesVersions lookups and (and, if there's exports present, blocks them) | ||
| !packageInfo.Contents.Exports.IsFalsy() { | ||
| // package exports are higher priority than file/directory/typesVersions lookups and (and, if there's exports present*, blocks them) | ||
| // *Well, weirdly enough a top-level `"exports": null` does NOT block fallback resolution. |
Comment on lines
+1126
to
+1127
| // package exports are higher priority than file/directory/typesVersions lookups and (and, if there's exports present*, blocks them) | ||
| // *Well, weirdly enough a top-level `"exports": null` does NOT block fallback resolution. |
jakebailey
approved these changes
May 8, 2026
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.
Closes #3479
Fixes a porting bug of microsoft/TypeScript#49327
Opened #3775 as a to-do after we move repos