print assignment pattern shorthand with matching key nicely

This commit is contained in:
Sebastian McKenzie 2015-05-20 10:44:36 +01:00
parent b36cf11ac8
commit c45ce61550

View File

@ -39,6 +39,12 @@ export function Property(node, print) {
print(node.key);
this.push("]");
} else {
// print `({ foo: foo = 5 } = {})` as `({ foo = 5 } = {});`
if (t.isAssignmentPattern(node.value) && t.isIdentifier(node.key) && node.key.name === node.value.left.name) {
print(node.value);
return;
}
print(node.key);
// shorthand!