Keep parens around FunctionTypeAnnotation inside ArrayTypeAnnotation (#2561)

Without this, this:

    const actionArray: (() => void)[] = [];

is formatted as:

    const actionArray: () => void[] = [];

Fixes #2559
This commit is contained in:
Lucas Azzola authored and GitHub committed 2017-07-30 00:50:38 +10:00
1 parent af6b020f7e
commit 58edd0d3f3
4 files changed
+12 -1

No files matched your search

+2 -1
View File
@@ -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":
@@ -0,0 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`array_of_functions.js 1`] = `
const actionArray: (() => void)[] = [];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const actionArray: (() => void)[] = [];
`;
@@ -0,0 +1 @@
const actionArray: (() => void)[] = [];
+1
View File
@@ -0,0 +1 @@
run_spec(__dirname, null, ["babylon"]);