From bc52e7a81df33aacda7f45ac97b123a02ccd48c8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Feb 2026 00:09:43 +0000 Subject: [PATCH 1/3] Initial plan From ab6e0ba2a5bb4f267f3926f4ee78d819ab686e22 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Feb 2026 00:48:12 +0000 Subject: [PATCH 2/3] Port TS#63043: Fix transform crash with destructured parameter property Implement walkBindingPattern in declaration emit to properly emit property declarations for destructured parameter properties. While parameter properties with binding patterns are an error (TS1187), the declaration emitter should still emit them correctly. The runtime transform crash fix was already ported (IsIdentifier checks in runtimesyntax.go). This change ports the remaining declaration emit behavior to match TypeScript. Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- .../transformers/declarations/transform.go | 22 ++++++++++++++- ...ionEmitDestructuringParameterProperties.js | 9 ++++++ ...itDestructuringParameterProperties.js.diff | 28 ------------------- ...onEmitDestructuringParameterProperties2.js | 9 ++++++ ...tDestructuringParameterProperties2.js.diff | 28 ------------------- 5 files changed, 39 insertions(+), 57 deletions(-) delete mode 100644 testdata/baselines/reference/submodule/compiler/declarationEmitDestructuringParameterProperties.js.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/declarationEmitDestructuringParameterProperties2.js.diff diff --git a/internal/transformers/declarations/transform.go b/internal/transformers/declarations/transform.go index 24e18fccd54..fb9b3e29f0f 100644 --- a/internal/transformers/declarations/transform.go +++ b/internal/transformers/declarations/transform.go @@ -1430,7 +1430,7 @@ func (tx *DeclarationTransformer) transformClassDeclaration(input *ast.ClassDecl parameterProperties = append(parameterProperties, updated) } else { // Pattern - this is currently an error, but we emit declarations for it somewhat correctly - // !!! is this worth reimplementing? We never made it not-an-error + parameterProperties = append(parameterProperties, tx.walkBindingPattern(param.Name().AsBindingPattern(), param)...) } } tx.state.getSymbolAccessibilityDiagnostic = oldDiag @@ -1542,6 +1542,26 @@ func (tx *DeclarationTransformer) transformClassDeclaration(input *ast.ClassDecl ) } +func (tx *DeclarationTransformer) walkBindingPattern(pattern *ast.BindingPattern, param *ast.Node) []*ast.Node { + var elems []*ast.Node + for _, elem := range pattern.Elements.Nodes { + if ast.IsOmittedExpression(elem) { + continue + } + if ast.IsBindingPattern(elem.Name()) { + elems = append(elems, tx.walkBindingPattern(elem.Name().AsBindingPattern(), param)...) + } + elems = append(elems, tx.Factory().NewPropertyDeclaration( + tx.ensureModifiers(param), + elem.Name(), + nil, /*questionOrExclamationToken*/ + tx.ensureType(elem, false), + nil, /*initializer*/ + )) + } + return elems +} + func (tx *DeclarationTransformer) transformVariableStatement(input *ast.VariableStatement) *ast.Node { visible := false for _, decl := range input.DeclarationList.AsVariableDeclarationList().Declarations.Nodes { diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitDestructuringParameterProperties.js b/testdata/baselines/reference/submodule/compiler/declarationEmitDestructuringParameterProperties.js index 425cdbb68d0..8dbb677bbff 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitDestructuringParameterProperties.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitDestructuringParameterProperties.js @@ -36,10 +36,16 @@ class C3 { //// [declarationEmitDestructuringParameterProperties.d.ts] declare class C1 { + x: string; + y: string; + z: string; constructor([x, y, z]: string[]); } type TupleType1 = [string, number, boolean]; declare class C2 { + x: string; + y: number; + z: boolean; constructor([x, y, z]: TupleType1); } type ObjType1 = { @@ -48,5 +54,8 @@ type ObjType1 = { z: boolean; }; declare class C3 { + x: number; + y: string; + z: boolean; constructor({ x, y, z }: ObjType1); } diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitDestructuringParameterProperties.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitDestructuringParameterProperties.js.diff deleted file mode 100644 index cf20bd06eaa..00000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitDestructuringParameterProperties.js.diff +++ /dev/null @@ -1,28 +0,0 @@ ---- old.declarationEmitDestructuringParameterProperties.js -+++ new.declarationEmitDestructuringParameterProperties.js -@@= skipped -35, +35 lines =@@ - - //// [declarationEmitDestructuringParameterProperties.d.ts] - declare class C1 { -- x: string; -- y: string; -- z: string; - constructor([x, y, z]: string[]); - } - type TupleType1 = [string, number, boolean]; - declare class C2 { -- x: string; -- y: number; -- z: boolean; - constructor([x, y, z]: TupleType1); - } - type ObjType1 = { -@@= skipped -18, +12 lines =@@ - z: boolean; - }; - declare class C3 { -- x: number; -- y: string; -- z: boolean; - constructor({ x, y, z }: ObjType1); - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitDestructuringParameterProperties2.js b/testdata/baselines/reference/submodule/compiler/declarationEmitDestructuringParameterProperties2.js index 487b2e131c4..1f50c2fcd1b 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitDestructuringParameterProperties2.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitDestructuringParameterProperties2.js @@ -36,10 +36,16 @@ class C3 { //// [declarationEmitDestructuringParameterProperties2.d.ts] declare class C1 { + x: string; + y: string; + z: string; constructor([x, y, z]: string[]); } type TupleType1 = [string, number, boolean]; declare class C2 { + x: string; + y: number; + z: boolean; constructor([x, y, z]: TupleType1); } type ObjType1 = { @@ -48,5 +54,8 @@ type ObjType1 = { z: boolean; }; declare class C3 { + x: number; + y: string; + z: boolean; constructor({ x, y, z }: ObjType1); } diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitDestructuringParameterProperties2.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitDestructuringParameterProperties2.js.diff deleted file mode 100644 index f0f4c441a4a..00000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitDestructuringParameterProperties2.js.diff +++ /dev/null @@ -1,28 +0,0 @@ ---- old.declarationEmitDestructuringParameterProperties2.js -+++ new.declarationEmitDestructuringParameterProperties2.js -@@= skipped -35, +35 lines =@@ - - //// [declarationEmitDestructuringParameterProperties2.d.ts] - declare class C1 { -- x: string; -- y: string; -- z: string; - constructor([x, y, z]: string[]); - } - type TupleType1 = [string, number, boolean]; - declare class C2 { -- x: string; -- y: number; -- z: boolean; - constructor([x, y, z]: TupleType1); - } - type ObjType1 = { -@@= skipped -18, +12 lines =@@ - z: boolean; - }; - declare class C3 { -- x: number; -- y: string; -- z: boolean; - constructor({ x, y, z }: ObjType1); - } \ No newline at end of file From 598ba8308514600166455f358c38195adec15296 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Feb 2026 00:39:40 +0000 Subject: [PATCH 3/3] Port TS#63154: Add continue after recursing into nested binding patterns When walkBindingPattern encounters a nested binding pattern, it should recurse and continue to the next element, not fall through to also emit a PropertyDeclaration with the binding pattern as a name (which would crash in the printer). Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- internal/transformers/declarations/transform.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/transformers/declarations/transform.go b/internal/transformers/declarations/transform.go index fb9b3e29f0f..3ae4002e774 100644 --- a/internal/transformers/declarations/transform.go +++ b/internal/transformers/declarations/transform.go @@ -1550,6 +1550,7 @@ func (tx *DeclarationTransformer) walkBindingPattern(pattern *ast.BindingPattern } if ast.IsBindingPattern(elem.Name()) { elems = append(elems, tx.walkBindingPattern(elem.Name().AsBindingPattern(), param)...) + continue } elems = append(elems, tx.Factory().NewPropertyDeclaration( tx.ensureModifiers(param),