Repository navigation
fix(64974): fix contextual typing for destructured parameter defaults - #64978
Open
Oleksandr Tarasiuk (a-tarasyuk) wants to merge 1 commit into
Open
Oleksandr Tarasiuk (a-tarasyuk) wants to merge 1 commit into
Oleksandr Tarasiuk (a-tarasyuk) wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🟢 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #64974