🤖 Pick PR #53665 (Fix crash when private id in array ...) into release-5.0 (#53677)

Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
This commit is contained in:
TypeScript Bot 2023-04-05 13:35:44 -07:00 committed by GitHub
parent b2d5d9b13f
commit 97dac8a261
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 33 additions and 4 deletions

View File

@ -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) {

View File

@ -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.

View File

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

View File

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

View File

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

View File

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