From 55b02449cf33623e68d434db8261d0db3069fcb3 Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Mon, 3 Apr 2017 13:08:52 +0200 Subject: [PATCH] Fix printing of exact object flow type annotations Fixes #1089. --- src/printer.js | 4 ++-- tests/exact_object/__snapshots__/jsfmt.spec.js.snap | 8 ++++++++ tests/exact_object/jsfmt.spec.js | 1 + tests/exact_object/test.js | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 tests/exact_object/__snapshots__/jsfmt.spec.js.snap create mode 100644 tests/exact_object/jsfmt.spec.js create mode 100644 tests/exact_object/test.js diff --git a/src/printer.js b/src/printer.js index 2c7fb157ecf7..1dec2400b4bd 100644 --- a/src/printer.js +++ b/src/printer.js @@ -704,10 +704,10 @@ function genericPrintNoParens(path, options, print) { if (props.length === 0) { return group( concat([ - "{", + leftBrace, comments.printDanglingComments(path, options), softline, - "}" + rightBrace ]) ); } else { diff --git a/tests/exact_object/__snapshots__/jsfmt.spec.js.snap b/tests/exact_object/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 000000000000..f2ac21e440e2 --- /dev/null +++ b/tests/exact_object/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,8 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`test.js 1`] = ` +"type Props = {||}; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +type Props = {||}; +" +`; diff --git a/tests/exact_object/jsfmt.spec.js b/tests/exact_object/jsfmt.spec.js new file mode 100644 index 000000000000..989047bccc52 --- /dev/null +++ b/tests/exact_object/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname); diff --git a/tests/exact_object/test.js b/tests/exact_object/test.js new file mode 100644 index 000000000000..046279e56bf2 --- /dev/null +++ b/tests/exact_object/test.js @@ -0,0 +1 @@ +type Props = {||};