Skip to content

Fix package index fallback edge case, accept self-name resolution errors under ambiguous project root#3776

Merged
andrewbranch merged 3 commits into
microsoft:mainfrom
andrewbranch:bug/3479
May 8, 2026
Merged

Fix package index fallback edge case, accept self-name resolution errors under ambiguous project root#3776
andrewbranch merged 3 commits into
microsoft:mainfrom
andrewbranch:bug/3479

Conversation

@andrewbranch

Copy link
Copy Markdown
Member

Closes #3479
Fixes a porting bug of microsoft/TypeScript#49327
Opened #3775 as a to-do after we move repos

Copilot AI review requested due to automatic review settings May 8, 2026 19:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 loadModuleFromSpecificNodeModulesDirectory to treat falsy exports (notably null) as not blocking fallback resolution.
  • Promote several module-resolution-related baseline diffs from submoduleTriaged to submoduleAccepted, with notes about rootDir-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.
@andrewbranch andrewbranch added this pull request to the merge queue May 8, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch May 8, 2026
@andrewbranch andrewbranch enabled auto-merge May 8, 2026 20:22
@andrewbranch andrewbranch requested a review from jakebailey May 8, 2026 20:22
@andrewbranch andrewbranch added this pull request to the merge queue May 8, 2026
Merged via the queue into microsoft:main with commit e1f8f97 May 8, 2026
21 checks passed
@andrewbranch andrewbranch deleted the bug/3479 branch May 8, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Untriaged differences in self-package resolution (possibly test harness only)

3 participants