Skip to content

Commit

Permalink
optional assign is not in general an lval (e.g. no [a?.b]=c)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Aug 2, 2023
1 parent a3202e1 commit 3311711
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
5 changes: 1 addition & 4 deletions packages/babel-types/src/ast-types/generated/index.ts
Expand Up @@ -311,7 +311,7 @@ export interface ArrayExpression extends BaseNode {
export interface AssignmentExpression extends BaseNode {
type: "AssignmentExpression";
operator: string;
left: LVal;
left: LVal | OptionalMemberExpression;
right: Expression;
}

Expand Down Expand Up @@ -2406,7 +2406,6 @@ export type LVal =
| AssignmentPattern
| ArrayPattern
| ObjectPattern
| OptionalMemberExpression
| TSParameterProperty
| TSAsExpression
| TSSatisfiesExpression
Expand Down Expand Up @@ -5788,7 +5787,6 @@ export interface ParentMaps {
| UnionTypeAnnotation;
OptionalMemberExpression:
| ArrayExpression
| ArrayPattern
| ArrowFunctionExpression
| AssignmentExpression
| AssignmentPattern
Expand Down Expand Up @@ -5824,7 +5822,6 @@ export interface ParentMaps {
| ParenthesizedExpression
| PipelineBareFunction
| PipelineTopicExpression
| RestElement
| ReturnStatement
| SequenceExpression
| SpreadElement
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-types/src/builders/generated/index.ts
Expand Up @@ -15,7 +15,7 @@ export function arrayExpression(
}
export function assignmentExpression(
operator: string,
left: t.LVal,
left: t.LVal | t.OptionalMemberExpression,
right: t.Expression,
): t.AssignmentExpression {
return validateNode<t.AssignmentExpression>({
Expand Down
5 changes: 3 additions & 2 deletions packages/babel-types/src/definitions/core.ts
Expand Up @@ -63,10 +63,11 @@ defineType("AssignmentExpression", {
},
left: {
validate: !process.env.BABEL_TYPES_8_BREAKING
? assertNodeType("LVal")
? assertNodeType("LVal", "OptionalMemberExpression")
: assertNodeType(
"Identifier",
"MemberExpression",
"OptionalMemberExpression",
"ArrayPattern",
"ObjectPattern",
"TSAsExpression",
Expand Down Expand Up @@ -2176,7 +2177,7 @@ defineType("ExportNamespaceSpecifier", {
defineType("OptionalMemberExpression", {
builder: ["object", "property", "computed", "optional"],
visitor: ["object", "property"],
aliases: ["Expression", "LVal"],
aliases: ["Expression"],
fields: {
object: {
validate: assertNodeType("Expression"),
Expand Down
1 change: 0 additions & 1 deletion packages/babel-types/src/validators/generated/index.ts
Expand Up @@ -3162,7 +3162,6 @@ export function isLVal(
case "AssignmentPattern":
case "ArrayPattern":
case "ObjectPattern":
case "OptionalMemberExpression":
case "TSParameterProperty":
case "TSAsExpression":
case "TSSatisfiesExpression":
Expand Down

0 comments on commit 3311711

Please sign in to comment.