Take the alternate existence into account

This commit is contained in:
Amjad Masad 2015-11-17 19:16:19 -08:00
parent 35e575cf93
commit 1612c70c10

View File

@ -16,8 +16,8 @@ export function IfStatement(node: Object) {
this.push(")");
this.space();
let consequentIsIf = t.isIfStatement(node.consequent);
if (consequentIsIf) {
let needsBlock = node.alternate && t.isIfStatement(node.consequent);
if (needsBlock) {
this.push("{");
this.newline();
this.indent();
@ -25,7 +25,7 @@ export function IfStatement(node: Object) {
this.printAndIndentOnComments(node.consequent, node);
if (consequentIsIf) {
if (needsBlock) {
this.dedent();
this.newline();
this.push("}");