Skip to content

Commit 97dac8a

Browse files
TypeScript Botjakebailey
TypeScript Bot
andauthored
🤖 Pick PR #53665 (Fix crash when private id in array ...) into release-5.0 (#53677)
Co-authored-by: Jake Bailey <[email protected]>
1 parent b2d5d9b commit 97dac8a

6 files changed

+33
-4
lines changed

‎src/compiler/transformers/classFields.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -2977,11 +2977,11 @@ export function transformClassFields(context: TransformationContext): (x: Source
29772977
}
29782978

29792979
function visitArrayAssignmentElement(node: Expression): Expression {
2980-
Debug.assertNode(node, isArrayBindingOrAssignmentElement);
2981-
if (isSpreadElement(node)) return visitAssignmentRestElement(node);
2982-
if (!isOmittedExpression(node)) return visitAssignmentElement(node);
2980+
if (isArrayBindingOrAssignmentElement(node)) {
2981+
if (isSpreadElement(node)) return visitAssignmentRestElement(node);
2982+
if (!isOmittedExpression(node)) return visitAssignmentElement(node);
2983+
}
29832984
return visitEachChild(node, visitor, context);
2984-
29852985
}
29862986

29872987
function visitAssignmentProperty(node: PropertyAssignment) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
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.
2+
tests/cases/compiler/parserPrivateIdentifierInArrayAssignment.ts(1,8): error TS1109: Expression expected.
3+
4+
5+
==== tests/cases/compiler/parserPrivateIdentifierInArrayAssignment.ts (2 errors) ====
6+
[#abc]=
7+
~~~~
8+
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
9+
10+
!!! error TS1109: Expression expected.
11+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//// [parserPrivateIdentifierInArrayAssignment.ts]
2+
[#abc]=
3+
4+
5+
//// [parserPrivateIdentifierInArrayAssignment.js]
6+
#abc = [0];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
=== tests/cases/compiler/parserPrivateIdentifierInArrayAssignment.ts ===
2+
3+
[#abc]=
4+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
=== tests/cases/compiler/parserPrivateIdentifierInArrayAssignment.ts ===
2+
[#abc]=
3+
>[#abc]= : any
4+
>[#abc] : [any]
5+
6+
> : any
7+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[#abc]=

0 commit comments

Comments
 (0)