Normalize distributed type parameters in conditional type relationships - #64307
Open
Mateusz Burzyński (Andarist) wants to merge 3 commits into
Open
Mateusz Burzyński (Andarist) wants to merge 3 commits into
Mateusz Burzyński (Andarist) wants to merge 3 commits into
Conversation
|
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
Copilot started reviewing on behalf of
Mateusz Burzyński (Andarist)
September 17, 2026 10:22
View session
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused normalization fix is consistent with the mapper behavior and has bidirectional regression coverage.
Pull request overview
Normalizes both sides of conditional true-branch relationships, restoring assignability for equivalent distributive conditional types.
Changes:
- Instantiates the target true type with the inference mapper.
- Adds a bidirectional regression test and generated baselines.
File summaries
| File | Description |
|---|---|
tsc/internal/checker/relater.go |
Normalizes the target conditional branch. |
tsc/testdata/tests/cases/conformance/types/conditional/conditionalTypes1.ts |
Adds regression coverage. |
tsc/testdata/baselines/reference/conformance/conditionalTypes1.types |
Updates type baseline. |
tsc/testdata/baselines/reference/conformance/conditionalTypes1.symbols |
Updates symbol baseline. |
tsc/testdata/baselines/reference/conformance/conditionalTypes1.js |
Updates emit and declaration baseline. |
tsc/testdata/baselines/reference/conformance/conditionalTypes1.errors.txt |
Confirms no new diagnostics. |
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
…non-distributed form Types declared inside a distributive conditional type reference the distributed form of the check type parameter. Instantiation maps those references back to the non-distributed form, but only for the parts of the type it actually rebuilds. Anonymous types and conditional types seed their instantiation cache with an identity entry that returns the declared type unchanged, so an inline object literal, function type, or nested conditional type kept the distributed type parameter after instantiation. Skip seeding that identity entry for types declared in a distributive context, and normalize both sides of a conditional-to-conditional relation (extends, true, and false types) with the non-distributing mapper so the comparison doesn't depend on whether either side has been instantiated.
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.
fixes a regression from #64237 , cc Anders Hejlsberg (@ahejlsberg)
The target type here needs to be instantiated too - so the
Tcan be mapped back to the non-distributed type parameter. The source type already does that mapping so the distributed type param on that side becomes non-distributed. But that creates an assymetry without mapping the target side too.