Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion tsc/internal/transformers/estransforms/classfields.go
Original file line number Diff line number Diff line change
Expand Up @@ -3318,7 +3318,6 @@ func (tx *classFieldsTransformer) visitAssignmentRestProperty(node *ast.Node) *a
}

func (tx *classFieldsTransformer) visitObjectAssignmentElement(node *ast.Node) *ast.Node {
debug.Assert(node != nil && ast.IsObjectBindingOrAssignmentElement(node))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me the assert here (and I've seen similar cases in the past) assumes a non-malformed source code. But those transformer paths still run over malformed nodes and it's the easiest to accept such subtrees

if ast.IsSpreadAssignment(node) {
return tx.visitAssignmentRestProperty(node)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
malformedObjectDestructuringAssignmentClassFields.ts(1,3): error TS1136: Property assignment expected.
malformedObjectDestructuringAssignmentClassFields.ts(1,6): error TS1005: ',' expected.
malformedObjectDestructuringAssignmentClassFields.ts(1,7): error TS1127: Invalid character.
malformedObjectDestructuringAssignmentClassFields.ts(1,10): error TS1109: Expression expected.
malformedObjectDestructuringAssignmentClassFields.ts(2,1): error TS1005: ')' expected.


==== malformedObjectDestructuringAssignmentClassFields.ts (5 errors) ====
({x(A.#}=
~
!!! error TS1136: Property assignment expected.
~
!!! error TS1005: ',' expected.
~
!!! error TS1127: Invalid character.

!!! error TS1109: Expression expected.


!!! error TS1005: ')' expected.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//// [tests/cases/compiler/malformedObjectDestructuringAssignmentClassFields.ts] ////

//// [malformedObjectDestructuringAssignmentClassFields.ts]
({x(A.#}=


//// [malformedObjectDestructuringAssignmentClassFields.js]
"use strict";
({ x(A) { }, : .# } =
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//// [tests/cases/compiler/malformedObjectDestructuringAssignmentClassFields.ts] ////

=== malformedObjectDestructuringAssignmentClassFields.ts ===
({x(A.#}=
>x : Symbol(x, Decl(malformedObjectDestructuringAssignmentClassFields.ts, 0, 2))
>A : Symbol(A, Decl(malformedObjectDestructuringAssignmentClassFields.ts, 0, 4))
> : Symbol((Missing), Decl(malformedObjectDestructuringAssignmentClassFields.ts, 0, 5))

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//// [tests/cases/compiler/malformedObjectDestructuringAssignmentClassFields.ts] ////

=== malformedObjectDestructuringAssignmentClassFields.ts ===
({x(A.#}=
>({x(A.#}= : any
>{x(A.#}= : any
>{x(A.#} : { x(A: any): any; "": any; }
>x : (A: any) => any
>A : any
> : any
>.# : any
> : any

> : any

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
({x(A.#}=
Loading