Skip to content

Commit 32fc7c9

Browse files
authored
Avoid removeNewlyUnusedIdentifiers when destructuring Arrays (#162)
Similar to #161, we have the same issue when encountering destructured Arrays. For now, I am skipping over these to avoid crashing.
1 parent 4457ce2 commit 32fc7c9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,11 @@ export default function(api) {
288288
let skippedIdentifiers = 0
289289
const removeNewlyUnusedIdentifiers = {
290290
VariableDeclarator(path) {
291-
if (path.node.id.type === 'ObjectPattern') {
292-
// Object destructuring, so we will want to capture all the names
293-
// created by the destructuring. This currently doesn't work, but
294-
// would be good to improve. All of the names can be collected
295-
// like:
291+
if (['ObjectPattern', 'ArrayPattern'].includes(path.node.id.type)) {
292+
// Object or Array destructuring, so we will want to capture all
293+
// the names created by the destructuring. This currently doesn't
294+
// work, but would be good to improve. All of the names for
295+
// ObjectPattern can be collected like:
296296
//
297297
// path.node.id.properties.map(prop => prop.value.name);
298298
return

0 commit comments

Comments
 (0)