Add parenthesis for single arg types with generics (#1814)

Fixes #1813
This commit is contained in:
Christopher Chedeau authored and GitHub committed 2017-05-29 16:59:45 -07:00
1 parent 2ab3d6d6ac
commit eeb8616e3c
3 files changed
+12

No files matched your search

+2
View File
@@ -3229,6 +3229,8 @@ function printFunctionParams(path, print, options, expandArg) {
fun[paramsField][0].typeAnnotation &&
flowTypeAnnotations.indexOf(fun[paramsField][0].typeAnnotation.type) !==
-1 &&
!(fun[paramsField][0].typeAnnotation.type === "GenericTypeAnnotation" &&
fun[paramsField][0].typeAnnotation.typeParameters) &&
!fun.rest;
if (isFlowShorthandWithOneArg) {
@@ -78,6 +78,8 @@ class X {
interface F {
ideConnectionFactoryLongLongLong: (child_process$ChildProcess) => FlowIDEConnection
}
type ExtractType = <A>(B<C>) => D
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
type Banana = {
eat: string => boolean
@@ -121,6 +123,8 @@ interface F {
ideConnectionFactoryLongLongLong: child_process$ChildProcess => FlowIDEConnection
}
type ExtractType = <A>(B<C>) => D;
`;
exports[`test.js 2`] = `
@@ -167,6 +171,8 @@ class X {
interface F {
ideConnectionFactoryLongLongLong: (child_process$ChildProcess) => FlowIDEConnection
}
type ExtractType = <A>(B<C>) => D
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
type Banana = {
eat: string => boolean,
@@ -210,4 +216,6 @@ interface F {
ideConnectionFactoryLongLongLong: child_process$ChildProcess => FlowIDEConnection,
}
type ExtractType = <A>(B<C>) => D;
`;
+2
View File
@@ -41,3 +41,5 @@ class X {
interface F {
ideConnectionFactoryLongLongLong: (child_process$ChildProcess) => FlowIDEConnection
}
type ExtractType = <A>(B<C>) => D