Skip to content

Commit

Permalink
Fix more TS
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Aug 2, 2023
1 parent 3311711 commit bdaa2c3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
6 changes: 5 additions & 1 deletion packages/babel-helper-function-name/src/index.ts
Expand Up @@ -224,7 +224,11 @@ export default function <N extends t.FunctionExpression | t.Class>(
node: N;
parent?: NodePath<N>["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,
Expand Down
Expand Up @@ -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;
};
Expand All @@ -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<any, void, any>,
Expand Down Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-transform-destructuring/src/index.ts
Expand Up @@ -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<t.AssignmentExpression & { left: t.Pattern }>,
name => state.addHelper(name),
arrayLikeIsIterable,
iterableIsArray,
Expand Down
6 changes: 3 additions & 3 deletions packages/babel-plugin-transform-destructuring/src/util.ts
Expand Up @@ -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;

Expand All @@ -155,7 +155,7 @@ export class DestructuringTransformer {
}

node = t.variableDeclaration(this.kind, [
t.variableDeclarator(id, nodeInit),
t.variableDeclarator(id as t.LVal, nodeInit),
]);
}

Expand Down Expand Up @@ -703,7 +703,7 @@ export function convertVariableDeclaration(
}

export function convertAssignmentExpression(
path: NodePath<t.AssignmentExpression>,
path: NodePath<t.AssignmentExpression & { left: t.Pattern }>,
addHelper: File["addHelper"],
arrayLikeIsIterable: boolean,
iterableIsArray: boolean,
Expand Down

0 comments on commit bdaa2c3

Please sign in to comment.