Fix identation with empty leading ObjectTypeProperty (#4862)

This commit is contained in:
Brian Ng 2016-11-19 09:47:41 -06:00 committed by Henry Zhu
parent 19bb830c50
commit 3a27f49c57
2 changed files with 24 additions and 0 deletions

View File

@ -270,6 +270,9 @@ export function ObjectTypeAnnotation(node: Object) {
this.space();
this.printJoin(props, node, {
addNewlines(leading) {
if (leading && !props[0]) return 1;
},
indent: true,
statement: true,
iterator: () => {

View File

@ -143,6 +143,27 @@ describe("programmatic generation", function() {
"}",
].join("\n"));
});
it("flow object indentation with empty leading ObjectTypeProperty", function() {
let objectStatement = t.objectTypeAnnotation(
[],
[
t.objectTypeIndexer(
t.identifier("key"),
t.anyTypeAnnotation(),
t.identifier("Test"),
),
]
);
let output = generate.default(objectStatement).code;
assert.equal(output, [
"{",
" [key: any]: Test;",
"}",
].join("\n"));
});
});
describe("whitespace", function () {