add test and fix for string literal case (#10578)

This commit is contained in:
Matthew Whitworth
2019-10-21 16:39:03 +01:00
committed by Nicolò Ribaudo
parent fe258dec04
commit 5b40845afe
2 changed files with 33 additions and 1 deletions

View File

@@ -281,7 +281,10 @@ export default {
path.replaceWith(
t.callExpression(state.addHelper("initializerDefineProperty"), [
t.cloneNode(path.get("left.object").node),
t.stringLiteral(path.get("left.property").node.name),
t.stringLiteral(
path.get("left.property").node.name ||
path.get("left.property").node.value,
),
t.cloneNode(path.get("right.arguments")[0].node),
t.cloneNode(path.get("right.arguments")[1].node),
]),