Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Commit

Permalink
fix(getVariableDeclarationIdentifiers): properly handle AssignmentPat…
Browse files Browse the repository at this point in the history
…tern
  • Loading branch information
fraxken committed Jan 15, 2023
1 parent e3c00ad commit fce1229
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/getVariableDeclarationIdentifiers.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,17 @@ export function* getVariableDeclarationIdentifiers(node, options = {}) {
break;

/**
* const [{ foo }] = []
* const [foo = 10] = []
* ↪ Destructuration + Assignement of a default value
*/
case "AssignmentPattern":
yield node.left.name;
if (node.left.type === "Identifier") {
yield node.left.name;
}
else {
yield* getVariableDeclarationIdentifiers(node.left);
}

break;

Expand Down

0 comments on commit fce1229

Please sign in to comment.