Skip to content

Port #62483: Disable conditional exports fallbacks on null values#2732

Merged
jakebailey merged 2 commits intomainfrom
copilot/disable-conditional-exports-fallbacks
Feb 11, 2026
Merged

Port #62483: Disable conditional exports fallbacks on null values#2732
jakebailey merged 2 commits intomainfrom
copilot/disable-conditional-exports-fallbacks

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 10, 2026

Ports microsoft/TypeScript#62483.

When a package.json conditional export maps a specifier to null, the resolver was treating it as "not found, keep searching," allowing fallback to subsequent conditions like types. Per Node.js semantics, null should terminate resolution for that entry.

{
  "exports": {
    ".": {
      "import": null,
      "types": "./dist/index.d.ts"
    }
  }
}

Previously, import: null would fall through to types, incorrectly resolving the module. Now it correctly stops resolution.

  • Changed the JSONValueTypeNull case in loadModuleFromTargetExportOrImport from continueSearching() to unresolved() — stops the search instead of falling through
  • Added result.isResolved() guard on the "Resolved under condition" trace — a null match shouldn't be traced as a resolution

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…ull values

When a package.json conditional export maps to null, stop searching
instead of falling through to other conditions. Also only emit
"Resolved under condition" trace when the result actually resolved.

Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot AI changed the title [WIP] Disable conditional exports fallbacks on null values Port #62483: Disable conditional exports fallbacks on null values Feb 10, 2026
Copilot AI requested a review from jakebailey February 10, 2026 22:42
@jakebailey jakebailey marked this pull request as ready for review February 10, 2026 22:45
Copilot AI review requested due to automatic review settings February 10, 2026 22:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Ports TypeScript #62483 to align package.json conditional exports resolution with Node.js semantics: when an exports/imports target is null, resolution should terminate for that entry (no fallback to later conditions like types).

Changes:

  • Treat JSONValueTypeNull targets as terminal-unresolved (unresolved()) instead of “keep searching” (continueSearching()).
  • Only emit the “Resolved under condition …” trace when the result is actually resolved.
  • Update conformance baselines to reflect that null blocks fallback and the module is not resolved.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/module/resolver.go Stops conditional exports resolution when a matched condition maps to null; prevents misleading “resolved” tracing for unresolved results.
testdata/baselines/reference/submodule/conformance/conditionalExportsResolutionFallbackNull(moduleresolution=nodenext).trace.json Updates trace to show resolution terminates on null and the module is not resolved.
testdata/baselines/reference/submodule/conformance/conditionalExportsResolutionFallbackNull(moduleresolution=nodenext).errors.txt Updates expected diagnostics to include the unresolved module error (TS2307).
testdata/baselines/reference/submodule/conformance/conditionalExportsResolutionFallbackNull(moduleresolution=nodenext).errors.txt.diff Removes outdated diff baseline content (no longer applicable).
testdata/baselines/reference/submodule/conformance/conditionalExportsResolutionFallbackNull(moduleresolution=node16).trace.json Same baseline update for node16 resolution mode.
testdata/baselines/reference/submodule/conformance/conditionalExportsResolutionFallbackNull(moduleresolution=node16).errors.txt Same expected diagnostic update for node16 resolution mode.
testdata/baselines/reference/submodule/conformance/conditionalExportsResolutionFallbackNull(moduleresolution=node16).errors.txt.diff Removes outdated diff baseline content (no longer applicable).
testdata/baselines/reference/submodule/conformance/conditionalExportsResolutionFallbackNull(moduleresolution=bundler).trace.json Same baseline update for bundler resolution mode.
testdata/baselines/reference/submodule/conformance/conditionalExportsResolutionFallbackNull(moduleresolution=bundler).errors.txt Adds expected TS2307 diagnostic baseline for bundler mode output.
testdata/baselines/reference/submodule/conformance/conditionalExportsResolutionFallbackNull(moduleresolution=bundler).errors.txt.diff Removes outdated diff baseline content (no longer applicable).

@jakebailey jakebailey enabled auto-merge February 10, 2026 23:24
@jakebailey jakebailey added this pull request to the merge queue Feb 10, 2026
Merged via the queue into main with commit 46cd072 Feb 11, 2026
26 checks passed
@jakebailey jakebailey deleted the copilot/disable-conditional-exports-fallbacks branch February 11, 2026 00:01
Copilot AI added a commit that referenced this pull request Feb 25, 2026
)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
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.

4 participants