[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:
piotr
2019-03-13 21:39:50 +01:00
committed by Nicolò Ribaudo
parent 29cd27b545
commit a64bf63639
5 changed files with 39 additions and 0 deletions

View File

@@ -76,6 +76,8 @@ export default declare((api, opts) => {
if (t.isIdentifier(prop.key) && !prop.computed) {
// since a key {a: 3} is equivalent to {"a": 3}, use the latter
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)) {
keys.push(t.stringLiteral(String(prop.key.value)));
} else {