babel-preset-modernize
babel-preset-modernize copied to clipboard
TypeError: Property argument of RestElement expected node to be of a type ["LVal"] but instead got undefined
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:
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:

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.
Thanks for the great issue! What you provided should be enough information for me to write up a test case and land a fix.
Hi ! Any updates here ?