-
Couldn't load subscription status.
- Fork 13.1k
Disable conditional exports fallbacks on null values
#62483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable conditional exports fallbacks on null values
#62483
Conversation
|
@typescript-bot test top400 |
There was a problem hiding this comment.
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 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 |
|
@andrewbranch Here are the results of running the top 400 repos with tsc comparing Everything looks good! |
Fixes #62439
Less ambitious version of #62310