Fix identation with empty leading ObjectTypeProperty (#4862)
This commit is contained in:
parent
19bb830c50
commit
3a27f49c57
@ -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: () => {
|
||||
|
||||
@ -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 () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user