account for parent NewExpression with arguments

This commit is contained in:
Henry Zhu 2015-12-05 13:37:06 -05:00
parent 8a1ad5350c
commit 21f76655ad
3 changed files with 9 additions and 2 deletions

View File

@ -63,7 +63,9 @@ 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;
!t.isCallExpression(parent, { callee: node }) &&
!t.isMemberExpression(parent) &&
!(t.isNewExpression(parent) && parent.arguments.length > 0)) return;
this.push("(");
this.printList(node.arguments, node);

View File

@ -1,3 +1,8 @@
new X();
new Y()();
new F().z;
new new x()();
new new x()(a);
new new x(a)();
new new x(a)(a);

View File

@ -1 +1 @@
new X;new Y()();new F().z;
new X;new Y()();new F().z;new new x;new new x()(a);new new x(a);new new x(a)(a);