Skip to content

Commit

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

Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
  • Loading branch information
2 people authored and dar committed Sep 14, 2023
1 parent af56b45 commit 1fb9f62
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
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
@@ -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.

@@ -0,0 +1,6 @@
//// [parserPrivateIdentifierInArrayAssignment.ts]
[#abc]=


//// [parserPrivateIdentifierInArrayAssignment.js]
#abc = [0];
@@ -0,0 +1,4 @@
=== tests/cases/compiler/parserPrivateIdentifierInArrayAssignment.ts ===

[#abc]=

@@ -0,0 +1,7 @@
=== tests/cases/compiler/parserPrivateIdentifierInArrayAssignment.ts ===
[#abc]=
>[#abc]= : any
>[#abc] : [any]

> : any

@@ -0,0 +1 @@
[#abc]=

0 comments on commit 1fb9f62

Please sign in to comment.