Skip to content

Fixed detection of optional chains containing a reference - #64232

Open
Mateusz Burzyński (Andarist) wants to merge 3 commits into
microsoft:mainfrom
Andarist:port-59144-optional-chain-reference
Open

Fixed detection of optional chains containing a reference#64232
Mateusz Burzyński (Andarist) wants to merge 3 commits into
microsoft:mainfrom
Andarist:port-59144-optional-chain-reference

Conversation

@Andarist

Copy link
Copy Markdown
Contributor

fixes #56998
fixes #60855

recreates #59144

Copilot AI balanced review requested due to automatic review settings September 10, 2026 16:53
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Sep 10, 2026
@typescript-automation typescript-automation Bot added the For Backlog Bug PRs that fix a backlog bug label Sep 10, 2026

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.

🟡 Changes recommended

The operand reversal regresses narrowing when an optional-chain base is wrapped in a satisfies expression.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Fixes control-flow narrowing for references assigned within optional-chain bases.

Changes:

  • Reverses reference matching to recognize assignment targets.
  • Adds regression and negative narrowing tests with baselines.
File summaries
File Description
tsc/internal/checker/flow.go Updates optional-chain reference matching.
tsc/testdata/tests/cases/conformance/controlFlow/controlFlowOptionalChain4.ts Adds regression cases.
tsc/testdata/baselines/reference/conformance/controlFlowOptionalChain4.types Records inferred types.
tsc/testdata/baselines/reference/conformance/controlFlowOptionalChain4.symbols Records resolved symbols.
tsc/testdata/baselines/reference/conformance/controlFlowOptionalChain4.errors.txt Records expected diagnostics.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread tsc/internal/checker/flow.go
@Andarist
Mateusz Burzyński (Andarist) force-pushed the port-59144-optional-chain-reference branch from c228f27 to 20fc192 Compare September 10, 2026 18:38
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

2 participants