Disable conditional exports fallbacks on `null` values by andrewbranch · Pull Request #62483 · microsoft/TypeScript
Pull Request Overview
This PR fixes handling of conditional exports when they map to null values by disabling fallback resolution behavior. The fix prevents TypeScript from continuing to search for modules when a package explicitly maps an export to null, which indicates the export is intentionally disabled.
Key changes:
- Modified module resolution logic to respect
nullexport mappings and stop fallback attempts - Updated tracing behavior to only log "Resolved under condition" when a non-null value is found
- Added comprehensive test coverage for various module resolution strategies
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/cases/conformance/moduleResolution/conditionalExportsResolutionFallbackNull.ts | Test case demonstrating the fix with a package that maps "import" to null |
| tests/baselines/reference/*.trace.json | Expected trace outputs showing module resolution stops at null mapping |
| tests/baselines/reference/*.errors.txt | Expected error outputs confirming module not found |
| src/compiler/moduleNameResolver.ts | Core fix to prevent fallback resolution on null mappings |