Use computed memberExpression for literal keys with object rest (#11550)
This commit is contained in:
parent
07347544fd
commit
9a52019019
@ -346,7 +346,11 @@ export default declare((api, opts) => {
|
||||
);
|
||||
refPropertyPath.forEach(prop => {
|
||||
const { node } = prop;
|
||||
ref = t.memberExpression(ref, t.cloneNode(node.key), node.computed);
|
||||
ref = t.memberExpression(
|
||||
ref,
|
||||
t.cloneNode(node.key),
|
||||
node.computed || t.isLiteral(node.key),
|
||||
);
|
||||
});
|
||||
|
||||
const objectPatternPath = path.findParent(path =>
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
let useState = [{ some: 42 }, () => null];
|
||||
|
||||
let {
|
||||
0: { numeric,...rest1 },
|
||||
'2': { str,...rest2 },
|
||||
1: setState,
|
||||
} = useState;
|
||||
@ -0,0 +1,14 @@
|
||||
let useState = [{
|
||||
some: 42
|
||||
}, () => null];
|
||||
let {
|
||||
0: {
|
||||
numeric
|
||||
},
|
||||
'2': {
|
||||
str
|
||||
},
|
||||
1: setState
|
||||
} = useState,
|
||||
rest1 = babelHelpers.objectWithoutProperties(useState[0], ["numeric"]),
|
||||
rest2 = babelHelpers.objectWithoutProperties(useState['2'], ["str"]);
|
||||
Loading…
x
Reference in New Issue
Block a user