Ensure directives get printed in block statements (#4873)

This commit is contained in:
Brian Ng
2016-12-16 14:30:14 -06:00
committed by Henry Zhu
parent 2bbc36d25e
commit 01bc43464e
8 changed files with 37 additions and 8 deletions

View File

@@ -14,11 +14,14 @@ export function Program(node: Object) {
export function BlockStatement(node: Object) {
this.token("{");
this.printInnerComments(node);
if (node.body.length) {
let hasDirectives = node.directives && node.directives.length;
if (node.body.length || hasDirectives) {
this.newline();
this.printSequence(node.directives, node, { indent: true });
if (node.directives && node.directives.length) this.newline();
if (hasDirectives) this.newline();
this.printSequence(node.body, node, { indent: true });
this.removeTrailingNewline();