babel-preset-modernize icon indicating copy to clipboard operation
babel-preset-modernize copied to clipboard

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

Open DreierF opened this issue 4 years ago • 2 comments

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:

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.

DreierF avatar Dec 12 '20 12:12 DreierF

Thanks for the great issue! What you provided should be enough information for me to write up a test case and land a fix.

developit avatar Dec 14 '20 02:12 developit

Hi ! Any updates here ?

darl0ck avatar Apr 20 '21 10:04 darl0ck