Merge pull request #3111 from amasad/new

No need for parens for new expressions without args
This commit is contained in:
Henry Zhu 2015-12-05 13:33:23 -05:00
commit 8a1ad5350c
3 changed files with 8 additions and 1 deletions

View File

@ -59,9 +59,12 @@ export function ConditionalExpression(node: Object) {
this.print(node.alternate, node);
}
export function NewExpression(node: Object) {
export function NewExpression(node: Object, parent: Object) {
this.push("new ");
this.print(node.callee, node);
if (node.arguments.length === 0 && this.format.compact &&
!t.isCallExpression(parent, { callee: node }) && !t.isMemberExpression(parent)) return;
this.push("(");
this.printList(node.arguments, node);
this.push(")");

View File

@ -0,0 +1,3 @@
new X();
new Y()();
new F().z;

View File

@ -0,0 +1 @@
new X;new Y()();new F().z;