Skip to content

Revert "Align object binding defaults with arrays" - #65556

Merged
Jake Bailey (jakebailey) merged 2 commits into
microsoft:mainfrom
jakebailey:revert-64043
Nov 18, 2026
Merged

Jake Bailey (jakebailey) merged 2 commits into
microsoft:mainfrom
jakebailey:revert-64043

Conversation

@jakebailey

Copy link
Copy Markdown
Member

Fixes #64431
Fixes #64974

Reopens #59920

Closes #64440
Closes #64671
Closes #64978
Closes #65070
Closes #65542

This reverts #64043, keeping its tests along with the cases from the issues above.

It's too close to 7.1 and I don't want to try and really fix this right now.

Padding a destructured parameter's default with its missing binding
elements adds them as implicitly any, even when an annotation, a JSDoc
@type signature, or a contextual type already types the parameter.
That reports implicit any on elements that have types (64431, 64974,
65011), and under a contextual type a nested default's elements become
any. Tuple defaults contextually typed by a tuple type have long
reported the same errors.
This reverts commit 07d1338 (64043),
keeping its tests.

Padding every missing binding element of a destructured parameter's
default made parameters with annotations or contextual types report
implicit any for elements that have types, and made nested elements
under a contextual type any. Restricting the padding to parameters
typed by their initializer fixes those cases, but the remaining
benefit, a better parameter type for unchecked JS (59920), is too
small to keep carrying a change in this area.

Fixes 64431
Fixes 64974

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

No active review issues are reported for the revert restoring prior object-binding default behavior.

No open issues 🎉

What changed in this PR

Reverts #64043’s object-binding default changes to address regressions #64431 and #64974 before TypeScript 7.1. This restores prior checker behavior while intentionally reopening #59920.

Changes:

  • Limits object-literal padding to binding elements with defaults and disables implicit-any reporting during that padding.
  • Preserves existing tests and adds contextual, annotated, nested, array, and JSDoc binding cases.
  • Updates type, symbol, and diagnostic baselines to reflect the revert.
File Description
tsc/​testdata/​tests/​cases/​compiler/​objectBindingPatternDefaultMissingElements.ts Adds regression cases for typed destructuring defaults.
tsc/​testdata/​baselines/​reference/​compiler/​objectBindingPatternDefaultMissingElements.types Records restored object signatures and new cases’ inferred types.
tsc/​testdata/​baselines/​reference/​compiler/​objectBindingPatternDefaultMissingElements.symbols Records symbol bindings for the added cases.
tsc/​testdata/​baselines/​reference/​compiler/​objectBindingPatternDefaultMissingElements.errors.txt Updates expected diagnostics, including unchanged tuple implicit-any errors.
tsc/​testdata/​baselines/​reference/​compiler/​inferredRestTypeFixedOnce.errors.txt Removes the implicit-any diagnostic baseline eliminated by the revert.
tsc/​internal/​checker/​checker.go Restores the previous object-literal padding behavior.

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Backlog Bug PRs that fix a backlog bug

Projects

Status: Done

4 participants