developit / developit/babel-preset-modernize

TypeError: Property argument of RestElement expected node to be of a type ["LVal"] but instead got undefined

Open
#2 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
119
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Hey 👋

I wanted to try out your optimize-plugin and ran into the following crash in transform-destructuring
```
errored out during transformation TypeError: .../dashboard.495836a2.js: Property argument of RestElement expected node to be of a type ["LVal"] but instead got undefined
at Object.validate (.../node_modules/@babel/types/lib/definitions/utils.js:132:11)
at validateField (.../node_modules/@babel/types/lib/validators/validate.js:24:9)
at validate (.../node_modules/@babel/types/lib/validators/validate.js:17:3)
at builder (.../node_modules/@babel/types/lib/builders/builder.js:38:27)
at Object.restElement (.../node_modules/@babel/types/lib/builders/generated/index.js:402:31)
at visitParam (.../node_modules/babel-preset-modernize/dist/plugins/transform-destructuring/index.js:1:5631)
at PluginPass.VariableDeclarator (.../node_modules/babel-preset-modernize/dist/plugins/transform-destructuring/index.js:1:7332)
at newFn (.../node_modules/@babel/traverse/lib/visitors.js:175:21)
at NodePath._call (.../node_modules/@babel/traverse/lib/path/context.js:55:20)
at NodePath.call (.../node_modules/@babel/traverse/lib/path/context.js:42:17) {
type: 'TypeError',
code: 'BABEL_TRANSFORM_ERROR'
}
```

The responsible line is [here](https://github.com/developit/babel-preset-modernize/blob/main/src/plugins/transform-destructuring/index.js#L344):
```js
let paramId;
if (isIterable) {
paramId = rest.node.id;
pattern[restOffset || pattern.length] = t.restElement(t.clone(paramId));
} else ...
```

`paramId` is undefined here. The rest object looks like this:

Screen Shot 2020-12-12 at 12 11 59

However I don't have any experience with babel plugins and no idea how I could extract more useful information from here.

Unfortunately I cannot share the code, but I can collect more information if you tell me what you need.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.