benjamn / ast-types

Esprima-compatible implementation of the Mozilla JS Parser API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Moved] Bug: Printing if statement inside bracketless if-else

adiba opened this issue · comments

commented

This

recast.print(
    b.ifStatement(
        b.literal(1), // test
        b.ifStatement(  // consequent
            b.literal(2), // - test
            b.expressionStatement(b.literal(3)) // - consequent
        ),
        b.expressionStatement(b.literal(4)) // alternate
    )
).code

produces:

if (1)
    if (2)
        3;
    else
        4;

but should produce this:

if (1)
{
    if (2)
        3;
} else
        4;

moved to benjamn/recast#416