Skip to content

Narrow by constant element access callees #62314

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Andarist
Copy link
Contributor

fixes #62247

@Copilot Copilot AI review requested due to automatic review settings August 21, 2025 19:08
@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Aug 21, 2025
@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Aug 21, 2025
Copy link

@Copilot 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 implements support for narrowing by type predicates when using element access expressions with constant arguments, addressing issue #62247. The fix allows TypeScript to properly narrow types when calling type predicate methods through computed property access with symbol keys.

Key Changes:

  • Enhanced type narrowing logic to support element access expressions with constant arguments in addition to property access expressions
  • Added comprehensive test coverage for the new functionality

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/compiler/checker.ts Updated type narrowing condition to include element access expressions with constant arguments
src/compiler/binder.ts Extended narrowable reference detection to support element access expressions
tests/cases/compiler/narrowByTypePredicateFromElementAccessExpression1.ts Added test case demonstrating type narrowing with symbol-based element access
tests/baselines/reference/narrowByTypePredicateFromElementAccessExpression1.types Generated baseline showing expected type information
tests/baselines/reference/narrowByTypePredicateFromElementAccessExpression1.symbols Generated baseline showing expected symbol resolution
Comments suppressed due to low confidence (1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Status: Not started
Development

Successfully merging this pull request may close these issues.

abstract type guard does not narrow when keyed with a unique symbol
2 participants