[proposal-object-rest-spread] fix templateLiteral in extractNormalizedKeys (#9628)
Added additional check in extractNormalizedKeys function to handle templates differently than string.
This commit is contained in:
parent
29cd27b545
commit
a64bf63639
@ -76,6 +76,8 @@ export default declare((api, opts) => {
|
|||||||
if (t.isIdentifier(prop.key) && !prop.computed) {
|
if (t.isIdentifier(prop.key) && !prop.computed) {
|
||||||
// since a key {a: 3} is equivalent to {"a": 3}, use the latter
|
// since a key {a: 3} is equivalent to {"a": 3}, use the latter
|
||||||
keys.push(t.stringLiteral(prop.key.name));
|
keys.push(t.stringLiteral(prop.key.name));
|
||||||
|
} else if (t.isTemplateLiteral(prop.key)) {
|
||||||
|
keys.push(t.cloneNode(prop.key));
|
||||||
} else if (t.isLiteral(prop.key)) {
|
} else if (t.isLiteral(prop.key)) {
|
||||||
keys.push(t.stringLiteral(String(prop.key.value)));
|
keys.push(t.stringLiteral(String(prop.key.value)));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -0,0 +1,10 @@
|
|||||||
|
const input = {};
|
||||||
|
|
||||||
|
const {
|
||||||
|
given_name: givenName,
|
||||||
|
'last_name': lastName,
|
||||||
|
[`country`]: country,
|
||||||
|
[prefix + 'state']: state,
|
||||||
|
[`${prefix}consents`]: consents,
|
||||||
|
...rest
|
||||||
|
} = input;
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
const input = {};
|
||||||
|
|
||||||
|
const _ref = prefix + 'state',
|
||||||
|
_ref2 = `${prefix}consents`,
|
||||||
|
{
|
||||||
|
given_name: givenName,
|
||||||
|
'last_name': lastName,
|
||||||
|
[`country`]: country,
|
||||||
|
[_ref]: state,
|
||||||
|
[_ref2]: consents
|
||||||
|
} = input,
|
||||||
|
rest = babelHelpers.objectWithoutProperties(input, ["given_name", "last_name", `country`, _ref, _ref2].map(babelHelpers.toPropertyKey));
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
const input = {};
|
||||||
|
|
||||||
|
const {
|
||||||
|
given_name: givenName,
|
||||||
|
'last_name': lastName,
|
||||||
|
[`country`]: country,
|
||||||
|
...rest
|
||||||
|
} = input;
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
const input = {};
|
||||||
|
const {
|
||||||
|
given_name: givenName,
|
||||||
|
'last_name': lastName,
|
||||||
|
[`country`]: country
|
||||||
|
} = input,
|
||||||
|
rest = babelHelpers.objectWithoutProperties(input, ["given_name", "last_name", `country`]);
|
||||||
Loading…
x
Reference in New Issue
Block a user