💻
How are you using Babel?
babel-loader (webpack)
Input code
REPL
for (const [{ ...rest }] = [{}]; false; );
Configuration file name
No response
Configuration
{
"plugins": ["@babel/plugin-transform-object-rest-spread"]
}
Current and expected behavior
Current: The transpiled code throws "_ref is not defined" error because the rest definition is moved out of the for loop.
// helper code omitted
for (const [_ref] = [{}]; false;);
var rest = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
Expected: This is valid JS, the transpiled code should not throw and initialize rest as an empty object.
Environment
REPL
Possible solution
No response
Additional context
This issue may be related to #17271, though the error message is different.