diff --git a/src/printer.js b/src/printer.js index c91d5946a..bf8234f15 100644 --- a/src/printer.js +++ b/src/printer.js @@ -1852,7 +1852,9 @@ function genericPrintNoParens(path, options, print, args) { case "TypeParameterDeclaration": case "TypeParameterInstantiation": { const shouldInline = - n.params.length === 1 && n.params[0].type === "ObjectTypeAnnotation"; + n.params.length === 1 && + (n.params[0].type === "ObjectTypeAnnotation" || + n.params[0].type === "NullableTypeAnnotation"); if (shouldInline) { return concat(["<", join(", ", path.map(print, "params")), ">"]); diff --git a/tests/flow_generic/__snapshots__/jsfmt.spec.js.snap b/tests/flow_generic/__snapshots__/jsfmt.spec.js.snap index eecfba4a2..e5981fbbd 100644 --- a/tests/flow_generic/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow_generic/__snapshots__/jsfmt.spec.js.snap @@ -54,6 +54,52 @@ var X = { `; +exports[`nullable.js 1`] = ` +function formatEntireFile( + fileVersion: FileVersion, + range: atom$Range, +): Promise {} + +function foo(): Promise {} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +function formatEntireFile( + fileVersion: FileVersion, + range: atom$Range +): Promise {} + +function foo(): Promise {} + +`; + +exports[`nullable.js 2`] = ` +function formatEntireFile( + fileVersion: FileVersion, + range: atom$Range, +): Promise {} + +function foo(): Promise {} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +function formatEntireFile( + fileVersion: FileVersion, + range: atom$Range, +): Promise {} + +function foo(): Promise {} + +`; + exports[`trailing.js 1`] = ` type State = { errors: Immutable.Map< diff --git a/tests/flow_generic/jsfmt.spec.js b/tests/flow_generic/jsfmt.spec.js index 220f446b5..ab1508e8d 100644 --- a/tests/flow_generic/jsfmt.spec.js +++ b/tests/flow_generic/jsfmt.spec.js @@ -1,2 +1,2 @@ -run_spec(__dirname); -run_spec(__dirname, { trailingComma: 'all' }); +run_spec(__dirname, null, ["babylon"]); +run_spec(__dirname, { trailingComma: 'all' }, ["babylon"]); diff --git a/tests/flow_generic/nullable.js b/tests/flow_generic/nullable.js new file mode 100644 index 000000000..d96187dc4 --- /dev/null +++ b/tests/flow_generic/nullable.js @@ -0,0 +1,9 @@ +function formatEntireFile( + fileVersion: FileVersion, + range: atom$Range, +): Promise {} + +function foo(): Promise {}