fix destructuring rest with template literal (#10013)
* fix destructuring rest with template literal * update test
This commit is contained in:
parent
a6392bd636
commit
b6486a22cb
@ -203,6 +203,8 @@ export default declare((api, options) => {
|
|||||||
const key = prop.key;
|
const key = prop.key;
|
||||||
if (t.isIdentifier(key) && !prop.computed) {
|
if (t.isIdentifier(key) && !prop.computed) {
|
||||||
keys.push(t.stringLiteral(key.name));
|
keys.push(t.stringLiteral(key.name));
|
||||||
|
} else if (t.isTemplateLiteral(prop.key)) {
|
||||||
|
keys.push(t.cloneNode(prop.key));
|
||||||
} else if (t.isLiteral(key)) {
|
} else if (t.isLiteral(key)) {
|
||||||
keys.push(t.stringLiteral(String(key.value)));
|
keys.push(t.stringLiteral(String(key.value)));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
10
packages/babel-plugin-transform-destructuring/test/fixtures/destructuring/issue-9834/input.js
vendored
Normal file
10
packages/babel-plugin-transform-destructuring/test/fixtures/destructuring/issue-9834/input.js
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
const input = {};
|
||||||
|
|
||||||
|
const {
|
||||||
|
given_name: givenName,
|
||||||
|
'last_name': lastName,
|
||||||
|
[`country`]: country,
|
||||||
|
[prefix + 'state']: state,
|
||||||
|
[`${prefix}consents`]: consents,
|
||||||
|
...rest
|
||||||
|
} = input;
|
||||||
10
packages/babel-plugin-transform-destructuring/test/fixtures/destructuring/issue-9834/output.js
vendored
Normal file
10
packages/babel-plugin-transform-destructuring/test/fixtures/destructuring/issue-9834/output.js
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
var input = {};
|
||||||
|
|
||||||
|
var _ref = prefix + 'state',
|
||||||
|
_ref2 = `${prefix}consents`,
|
||||||
|
givenName = input.given_name,
|
||||||
|
lastName = input['last_name'],
|
||||||
|
country = input[`country`],
|
||||||
|
state = input[_ref],
|
||||||
|
consents = input[_ref2],
|
||||||
|
rest = babelHelpers.objectWithoutProperties(input, ["given_name", "last_name", `country`, _ref, _ref2].map(babelHelpers.toPropertyKey));
|
||||||
Loading…
x
Reference in New Issue
Block a user