babel/packages/babel-generator
Amjad Masad 47b686b6fa Handle nested if statements with alternates in printer
Previously we saw a bug that when we have nested if statements
and an alternate then the generated code may confuse which
if statement the alternate belongs to.

e.g.

```
if (foo) if (bar) bar(); else baz();
```

But this was handled by looking at the consequent
and if it's an if we add a block. However we didn't
handle situations where it's not an if but the last
recursive statement is an if:

```
if (foo) while (bar) if (baz) baz(); else shoosh()
```

This handles it by recurring until we get the last
statement.
2015-12-17 22:41:55 -08:00
..
2015-12-16 12:24:45 -08:00
2015-10-29 19:28:05 -07:00

babel-generator

Turns an AST into code.

Install

$ npm install babel-generator

Usage

import {parse} from 'babylon';
import generate from 'babel-generator';

const code = 'class Example {}';
const ast = parse(ast);

const output = generate(ast, { /* options */ }, code);