Skip to content

Commit

Permalink
🤖 Pick PR #53665 (Fix crash when private id in array ...) into releas…
Browse files Browse the repository at this point in the history
…e-5.0 (#53677)

Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
  • Loading branch information
TypeScript Bot and jakebailey authored Apr 5, 2023
1 parent b2d5d9b commit 97dac8a
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/compiler/transformers/classFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2977,11 +2977,11 @@ export function transformClassFields(context: TransformationContext): (x: Source
}

function visitArrayAssignmentElement(node: Expression): Expression {
Debug.assertNode(node, isArrayBindingOrAssignmentElement);
if (isSpreadElement(node)) return visitAssignmentRestElement(node);
if (!isOmittedExpression(node)) return visitAssignmentElement(node);
if (isArrayBindingOrAssignmentElement(node)) {
if (isSpreadElement(node)) return visitAssignmentRestElement(node);
if (!isOmittedExpression(node)) return visitAssignmentElement(node);
}
return visitEachChild(node, visitor, context);

}

function visitAssignmentProperty(node: PropertyAssignment) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
tests/cases/compiler/parserPrivateIdentifierInArrayAssignment.ts(1,2): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/compiler/parserPrivateIdentifierInArrayAssignment.ts(1,8): error TS1109: Expression expected.


==== tests/cases/compiler/parserPrivateIdentifierInArrayAssignment.ts (2 errors) ====
[#abc]=
~~~~
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.

!!! error TS1109: Expression expected.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//// [parserPrivateIdentifierInArrayAssignment.ts]
[#abc]=


//// [parserPrivateIdentifierInArrayAssignment.js]
#abc = [0];
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
=== tests/cases/compiler/parserPrivateIdentifierInArrayAssignment.ts ===

[#abc]=

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
=== tests/cases/compiler/parserPrivateIdentifierInArrayAssignment.ts ===
[#abc]=
>[#abc]= : any
>[#abc] : [any]

> : any

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[#abc]=

0 comments on commit 97dac8a

Please sign in to comment.