Ensure arrow function bodies are wrapped in parens if needed.
Closes #1214.
This commit is contained in:
parent
77c72bb5a6
commit
80f109efeb
@ -75,5 +75,16 @@ export function ArrowFunctionExpression(node, print) {
|
||||
}
|
||||
|
||||
this.push(" => ");
|
||||
|
||||
const bodyNeedsParens = t.isObjectExpression(node.body);
|
||||
|
||||
if (bodyNeedsParens) {
|
||||
this.push("(");
|
||||
}
|
||||
|
||||
print(node.body);
|
||||
|
||||
if (bodyNeedsParens) {
|
||||
this.push(")");
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
var foo = arr.map(v => ({
|
||||
x: v.bar,
|
||||
y: v.bar*2
|
||||
}));
|
||||
@ -0,0 +1,4 @@
|
||||
var foo = arr.map(v => ({
|
||||
x: v.bar,
|
||||
y: v.bar * 2
|
||||
}));
|
||||
Loading…
x
Reference in New Issue
Block a user