Skip to content

Fix crash in declaration emit with nested binding patterns#63154

Merged
DanielRosenwasser merged 3 commits intomainfrom
copilot/fix-nested-binding-pattern-crash
Feb 18, 2026
Merged

Fix crash in declaration emit with nested binding patterns#63154
DanielRosenwasser merged 3 commits intomainfrom
copilot/fix-nested-binding-pattern-crash

Conversation

Copy link
Contributor

Copilot AI commented Feb 17, 2026

Fixes crash when emitting declarations for parameter properties with nested binding patterns:

// @declaration: true
export class C {
  constructor(public [[x]]: any[]) {}  // Previously crashed, now emits correctly
}

Root cause: walkBindingPattern recursively processed nested patterns but continued execution, attempting to use the binding pattern as an Identifier, causing Cannot read properties of undefined (reading 'id').

Fix: Add continue after recursive call to skip identifier handling for nested patterns.

Changes:

  • src/compiler/transformers/declarations.ts: Add continue statement in walkBindingPattern when encountering nested binding patterns
  • tests/cases/compiler/declarationEmitNestedBindingPattern.ts: Add test coverage for various nested binding pattern scenarios (array, object, mixed, multiple levels)
Original prompt

This section details on the original issue you should resolve

<issue_title>Crash for declaration emit with nested binding pattern</issue_title>
<issue_description>```ts
// @declaration: true

export class C {
constructor(public [[x]]: any[]) {}
}


TypeError: Cannot read properties of undefined (reading 'id')
at getSymbolId (D:\TypeScript\node_modules\typescript\lib_tsc.js:45937:15)
at Object.serializeTypeOfDeclaration (D:\TypeScript\node_modules\typescript\lib_tsc.js:50200:82)
at inferTypeOfDeclaration (D:\TypeScript\node_modules\typescript\lib_tsc.js:131867:21)
at Object.serializeTypeOfDeclaration (D:\TypeScript\node_modules\typescript\lib_tsc.js:131677:16)
at D:\TypeScript\node_modules\typescript\lib_tsc.js:50332:213
at withContext (D:\TypeScript\node_modules\typescript\lib_tsc.js:50427:29)
at Object.serializeTypeForDeclaration (D:\TypeScript\node_modules\typescript\lib_tsc.js:50332:114)
at Object.createTypeOfDeclaration (D:\TypeScript\node_modules\typescript\lib_tsc.js:86719:24)
at ensureType (D:\TypeScript\node_modules\typescript\lib_tsc.js:112711:27)
at walkBindingPattern (D:\TypeScript\node_modules\typescript\lib_tsc.js:113594:19)


## Comments on the Issue (you are @copilot in this section)

<comments>
<comment_new><author>@DanielRosenwasser</author><body>
Basically we just need to adjust `walkBindingPattern` to continue when it hits a binding pattern. Would be good to get some more tests with different types of binding patterns at different levels.</body></comment_new>
</comments>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Feb 17, 2026
Copilot AI and others added 2 commits February 17, 2026 22:50
- Added continue statement when walking nested binding patterns
- Added comprehensive test cases covering various nested binding patterns

Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix crash for declaration emit with nested binding pattern Fix crash in declaration emit with nested binding patterns Feb 17, 2026
Copy link
Contributor

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

Fixes a crash in the declaration emit transformer when encountering nested binding patterns inside (invalid-but-emitted) parameter properties, ensuring the emitter no longer attempts to treat a BindingPattern as an Identifier.

Changes:

  • Adjust walkBindingPattern to continue after recursively processing nested binding patterns, preventing incorrect identifier handling.
  • Add a compiler test covering nested array/object/mixed binding patterns in parameter properties and capture new baselines.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

File Description
src/compiler/transformers/declarations.ts Prevents crash in parameter-property declaration emit by skipping identifier path for nested binding patterns.
tests/cases/compiler/declarationEmitNestedBindingPattern.ts Adds regression coverage for multiple nested binding pattern shapes/levels.
tests/baselines/reference/declarationEmitNestedBindingPattern.* Baselines validating no crash and stable emit/type/symbol/error outputs.

@DanielRosenwasser DanielRosenwasser added this pull request to the merge queue Feb 18, 2026
Merged via the queue into main with commit ad04bf7 Feb 18, 2026
29 checks passed
@DanielRosenwasser DanielRosenwasser deleted the copilot/fix-nested-binding-pattern-crash branch February 18, 2026 00:45
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

None yet

Development

Successfully merging this pull request may close these issues.

Crash for declaration emit with nested binding pattern

4 participants