Fixed incorrect newlines with Flow object types (#3548)

This commit is contained in:
Sam Pepose
2016-06-23 17:38:05 -07:00
committed by Henry Zhu
parent 115a6543ab
commit 3ee06187d5
2 changed files with 21 additions and 1 deletions

View File

@@ -167,6 +167,7 @@ exports.nodes = {
*/
exports.nodes.ObjectProperty =
exports.nodes.ObjectTypeProperty =
exports.nodes.ObjectMethod =
exports.nodes.SpreadProperty = function (node: Object, parent): ?WhitespaceObject {
if (parent.properties[0] === node) {

View File

@@ -82,8 +82,27 @@ suite("programmatic generation", function() {
var ast = parse(generate.default(ifStatement).code);
assert.equal(ast.program.body[0].consequent.type, 'BlockStatement');
});
});
test("flow object indentation", function() {
var objectStatement = t.objectTypeAnnotation(
[
t.objectTypeProperty(
t.identifier('bar'),
t.stringTypeAnnotation()
),
],
null,
null
);
var output = generate.default(objectStatement).code;
assert.equal(output, [
'{',
' bar: string;',
'}',
].join('\n'));
});
});
suite("whitespace", function () {
test("empty token list", function () {