diff --git a/src/fast-path.js b/src/fast-path.js index 2d3d1f12c..fdc4deacb 100644 --- a/src/fast-path.js +++ b/src/fast-path.js @@ -458,7 +458,8 @@ FastPath.prototype.needsParens = function(options) { case "FunctionTypeAnnotation": return ( parent.type === "UnionTypeAnnotation" || - parent.type === "IntersectionTypeAnnotation" + parent.type === "IntersectionTypeAnnotation" || + parent.type === "ArrayTypeAnnotation" ); case "StringLiteral": diff --git a/tests/flow_annotation/__snapshots__/jsfmt.spec.js.snap b/tests/flow_annotation/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 000000000..868517a02 --- /dev/null +++ b/tests/flow_annotation/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,8 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`array_of_functions.js 1`] = ` +const actionArray: (() => void)[] = []; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +const actionArray: (() => void)[] = []; + +`; diff --git a/tests/flow_annotation/array_of_functions.js b/tests/flow_annotation/array_of_functions.js new file mode 100644 index 000000000..6125d8b0a --- /dev/null +++ b/tests/flow_annotation/array_of_functions.js @@ -0,0 +1 @@ +const actionArray: (() => void)[] = []; diff --git a/tests/flow_annotation/jsfmt.spec.js b/tests/flow_annotation/jsfmt.spec.js new file mode 100644 index 000000000..1840e9d36 --- /dev/null +++ b/tests/flow_annotation/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, null, ["babylon"]);