Skip to content

Normalize distributed type parameters in conditional type relationships - #64307

Open
Mateusz Burzyński (Andarist) wants to merge 3 commits into
microsoft:mainfrom
Andarist:distributed-conditional-type-relationships
Open

Mateusz Burzyński (Andarist) wants to merge 3 commits into
microsoft:mainfrom
Andarist:distributed-conditional-type-relationships

Conversation

@Andarist

Copy link
Copy Markdown
Contributor

fixes a regression from #64237 , cc Anders Hejlsberg (@ahejlsberg)

The target type here needs to be instantiated too - so the T can 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.

Copilot AI balanced review requested due to automatic review settings September 17, 2026 10:21
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Sep 17, 2026
@typescript-automation typescript-automation Bot added For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Sep 17, 2026
@typescript-automation

Copy link
Copy Markdown

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

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.

🟢 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.

feditfear123

This comment was marked as abuse.

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

3 participants