Skip to content

fix(64974): fix contextual typing for destructured parameter defaults - #64978

Open
Oleksandr Tarasiuk (a-tarasyuk) wants to merge 1 commit into
microsoft:mainfrom
a-tarasyuk:fix/64974
Open

Oleksandr Tarasiuk (a-tarasyuk) wants to merge 1 commit into
microsoft:mainfrom
a-tarasyuk:fix/64974

Conversation

@a-tarasyuk

Copy link
Copy Markdown
Contributor

Fixes #64974

Copilot AI balanced review requested due to automatic review settings October 27, 2026 10:08
@typescript-automation typescript-automation Bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Oct 27, 2026
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Oct 27, 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.

🟢 Approval recommended

Static review identified no blocking issues in the focused fix and regression baselines; automated validation was not run.

No open issues 🎉

What changed in this PR

Fixes #64974 by preserving contextual types for destructured parameter defaults, preventing incorrect TS7031 errors.

Changes:

  • Skip object-literal padding when the root parameter has a contextual type.
  • Add regression cases for optional parameters, nested destructuring, arrays, index signatures, and generic callbacks.
  • Update type, symbol, and diagnostic baselines.
File Description
tsc/​testdata/​tests/​cases/​compiler/​objectBindingPatternDefaultMissingElements.ts Adds contextual-typing regression cases.
tsc/​testdata/​baselines/​reference/​compiler/​objectBindingPatternDefaultMissingElements.types Records expected inferred types.
tsc/​testdata/​baselines/​reference/​compiler/​objectBindingPatternDefaultMissingElements.symbols Records symbols for the added cases.
tsc/​testdata/​baselines/​reference/​compiler/​objectBindingPatternDefaultMissingElements.errors.txt Records expected diagnostics without spurious implicit-any errors.
tsc/​internal/​checker/​checker.go Guards object-literal padding to preserve contextual typing.

Review effort: Balanced

This branch has not been deployed

No deployments
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.

7.1: destructured parameter with a = {} default loses its contextual type (TS7031)

2 participants