Allow patterns as argument of RestElement (#8414)
This commit is contained in:
committed by
Nicolò Ribaudo
parent
d9149aa2f3
commit
9eef660daa
@@ -228,10 +228,20 @@ export default function convertFunctionRest(path) {
|
||||
const { node, scope } = path;
|
||||
if (!hasRest(node)) return false;
|
||||
|
||||
const rest = node.params.pop().argument;
|
||||
let rest = node.params.pop().argument;
|
||||
|
||||
const argsId = t.identifier("arguments");
|
||||
|
||||
if (t.isPattern(rest)) {
|
||||
const pattern = rest;
|
||||
rest = scope.generateUidIdentifier("ref");
|
||||
|
||||
const declar = t.variableDeclaration("let", [
|
||||
t.variableDeclarator(pattern, rest),
|
||||
]);
|
||||
node.body.body.unshift(declar);
|
||||
}
|
||||
|
||||
// check and optimise for extremely common cases
|
||||
const state = {
|
||||
references: [],
|
||||
|
||||
Reference in New Issue
Block a user