Skip to content

Conversation

@Andarist
Copy link
Contributor

@Andarist Andarist commented May 8, 2025

fixes #61676

Copilot AI review requested due to automatic review settings May 8, 2025 21:50
@github-project-automation github-project-automation bot moved this to Not started in PR Backlog May 8, 2025
@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label May 8, 2025
Copy link
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

This PR fixes #61676 by improving how mapped type generic indexed accesses relate to their base constraints. Key changes include adding two new test cases (correlatedUnions3.ts and correlatedUnions2.ts) to confirm expected behavior and updating the type checker (in src/compiler/checker.ts) to correctly handle mapped type generic indexed accesses by using base constraints from target types.

Reviewed Changes

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

File Description
tests/cases/compiler/correlatedUnions3.ts Adds a new test case to verify behavior with optional callbacks.
tests/cases/compiler/correlatedUnions2.ts Updates an existing test case to reflect stricter callback requirements.
src/compiler/checker.ts Updates the type checking logic to incorporate a new branch for mapped type generic indexed accesses.
Files not reviewed (4)
  • tests/baselines/reference/correlatedUnions2.symbols: Language not supported
  • tests/baselines/reference/correlatedUnions2.types: Language not supported
  • tests/baselines/reference/correlatedUnions3.symbols: Language not supported
  • tests/baselines/reference/correlatedUnions3.types: Language not supported
Comments suppressed due to low confidence (2)

src/compiler/checker.ts:23518

  • [nitpick] Consider renaming 'constraint' to a more descriptive name, such as 'baseConstraint' or 'mappedConstraint', to clarify its dual use on both branches in this function.
let constraint;

src/compiler/checker.ts:23520

  • Ensure that the branch for mapped type generic indexed accesses handles all edge cases correctly when getBaseConstraintOfType(target) returns a falsy value. It may help to add a clarifying comment and additional tests to verify the intended behavior.
if ( isMappedTypeGenericIndexedAccess(target) && (constraint = getBaseConstraintOfType(target)) && (result = isRelatedTo(source, constraint, RecursionFlags.Target, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) ) {

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.

A contextually-typed signature coming from correlated union can't be assigned back to source of its contextual type

2 participants