diff --git a/packages/babel-helper-function-name/src/index.ts b/packages/babel-helper-function-name/src/index.ts index 48be2c9bb0b5..176d97e0b9c0 100644 --- a/packages/babel-helper-function-name/src/index.ts +++ b/packages/babel-helper-function-name/src/index.ts @@ -224,7 +224,11 @@ export default function ( node: N; parent?: NodePath["parent"]; scope: Scope; - id?: t.LVal | t.StringLiteral | t.NumericLiteral | t.BigIntLiteral; + id?: + | t.AssignmentExpression["left"] + | t.StringLiteral + | t.NumericLiteral + | t.BigIntLiteral; }, localBinding = false, supportUnicodeId = false, diff --git a/packages/babel-plugin-proposal-destructuring-private/src/util.ts b/packages/babel-plugin-proposal-destructuring-private/src/util.ts index f674c08a01f2..c5eb72f8ac90 100644 --- a/packages/babel-plugin-proposal-destructuring-private/src/util.ts +++ b/packages/babel-plugin-proposal-destructuring-private/src/util.ts @@ -151,7 +151,7 @@ function buildAssignmentsFromPatternList( } type StackItem = { - node: t.LVal | t.ObjectProperty | null; + node: t.AssignmentExpression["left"] | t.ObjectProperty | null; index: number; depth: number; }; @@ -169,9 +169,9 @@ type StackItem = { * @param visitor */ export function* traversePattern( - root: t.LVal, + root: t.AssignmentExpression["left"], visitor: ( - node: t.LVal | t.ObjectProperty, + node: t.AssignmentExpression["left"] | t.ObjectProperty, index: number, depth: number, ) => Generator, @@ -221,7 +221,7 @@ export function* traversePattern( } } -export function hasPrivateKeys(pattern: t.LVal) { +export function hasPrivateKeys(pattern: t.AssignmentExpression["left"]) { let result = false; traversePattern(pattern, function* (node) { if (isObjectProperty(node) && isPrivateName(node.key)) { diff --git a/packages/babel-plugin-transform-destructuring/src/index.ts b/packages/babel-plugin-transform-destructuring/src/index.ts index 3f7f8672768f..45edc004e536 100644 --- a/packages/babel-plugin-transform-destructuring/src/index.ts +++ b/packages/babel-plugin-transform-destructuring/src/index.ts @@ -158,7 +158,7 @@ export default declare((api, options: Options) => { AssignmentExpression(path, state) { if (!t.isPattern(path.node.left)) return; convertAssignmentExpression( - path, + path as NodePath, name => state.addHelper(name), arrayLikeIsIterable, iterableIsArray, diff --git a/packages/babel-plugin-transform-destructuring/src/util.ts b/packages/babel-plugin-transform-destructuring/src/util.ts index 10c3294d5f15..c8a33d222812 100644 --- a/packages/babel-plugin-transform-destructuring/src/util.ts +++ b/packages/babel-plugin-transform-destructuring/src/util.ts @@ -133,7 +133,7 @@ export class DestructuringTransformer { init: t.Expression, ) { let op = this.operator; - if (t.isMemberExpression(id)) op = "="; + if (t.isMemberExpression(id) || t.isOptionalMemberExpression(id)) op = "="; let node: t.ExpressionStatement | t.VariableDeclaration; @@ -155,7 +155,7 @@ export class DestructuringTransformer { } node = t.variableDeclaration(this.kind, [ - t.variableDeclarator(id, nodeInit), + t.variableDeclarator(id as t.LVal, nodeInit), ]); } @@ -703,7 +703,7 @@ export function convertVariableDeclaration( } export function convertAssignmentExpression( - path: NodePath, + path: NodePath, addHelper: File["addHelper"], arrayLikeIsIterable: boolean, iterableIsArray: boolean,