Repository: prettier/prettier (JavaScript)
Task: Bug Fix (2017-12-31 14:21:24+00:00)

Issue:
Arrow parens are not preserved in `FunctionTypeAnnotation`s when using "always" arrow parens option
**Prettier 1.9.2**
[Playground link](https://prettier.io/playground/#N4Igxg9gdgLgprEAuEMCeAHOACAyhAWzgBVMcBebYAHSm2wGdC4YALASygHMlsAKKAFcCAIzgAnAJTZyAPmxDRE2gF8A3LRAAaEBAwx20BslABDceIgB3AArmExlKYA2V02mM7TDGMgBmLgxwOiLipmAA1iy4GOGcXMgw4oLBIAAmEGD+gamcQeIwNmFcBKbZzkE6AFYMAB4AQmGR0aZEADKccOWVuoIwGH0ATN2pseL5yCAipiJoztDaIBjinDAA6uxpbMgAHAAMOssQQWthGJPLcPkAbl064nAAjoLsD0WmJWVIARWpQQTsRLJP7xZxwACKggg8BGOhgMw2W1YyEGcLC7Gc8QAwoRSpMoNA7iBBEFiDNHD8gioVEA)
```sh
--arrow-parens always
```

**Input:**
```jsx
type SomeType = {
  something: (number) => number
};

```

**Output:**
```jsx
type SomeType = {
  something: number => number
};

```


Discussion:
Actually, it's just flow, not typescript.

Patch:
diff --git a/src/language-js/printer-estree.js b/src/language-js/printer-estree.js
index 09fbf017a517..fd52d8d2caa8 100644
--- a/src/language-js/printer-estree.js
+++ b/src/language-js/printer-estree.js
@@ -3285,6 +3285,9 @@ function printFunctionParams(path, print, options, expandArg, printTypeParams) {
     !fun.rest;
 
   if (isFlowShorthandWithOneArg) {
+    if (options.arrowParens === "always") {
+      return concat(["(", concat(printed), ")"]);
+    }
     return concat(printed);
   }
 


Test patch:
diff --git a/tests/flow_function_parentheses/__snapshots__/jsfmt.spec.js.snap b/tests/flow_function_parentheses/__snapshots__/jsfmt.spec.js.snap
index f193c2ffba24..995d58e33472 100644
--- a/tests/flow_function_parentheses/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow_function_parentheses/__snapshots__/jsfmt.spec.js.snap
@@ -34,6 +34,23 @@ const selectorByPath: Path => SomethingSelector<
 
 `;
 
+exports[`single.js 3`] = `
+const selectorByPath:
+  Path
+ => SomethingSelector<
+  SomethingUEditorContextType,
+  SomethingUEditorContextType,
+  SomethingBulkValue<string>
+> = memoizeWithArgs(/* ... */)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+const selectorByPath: (Path) => SomethingSelector<
+  SomethingUEditorContextType,
+  SomethingUEditorContextType,
+  SomethingBulkValue<string>
+> = memoizeWithArgs(/* ... */);
+
+`;
+
 exports[`test.js 1`] = `
 type Banana = {
   eat: string => boolean,
@@ -219,3 +236,96 @@ interface F {
 type ExtractType = <A>(B<C>) => D;
 
 `;
+
+exports[`test.js 3`] = `
+type Banana = {
+  eat: string => boolean,
+};
+
+type Hex = {n: 0x01};
+
+type T = { method: (a) => void };
+
+type T = { method(a): void };
+
+declare class X { method(a): void }
+
+declare function f(a): void;
+
+var f: (a) => void;
+
+interface F { m(string): number }
+
+interface F { m: (string) => number }
+
+function f(o: { f: (string) => void }) {}
+
+function f(o: { f(string): void }) {}
+
+type f = (...arg) => void;
+
+type f = (/* comment */ arg) => void;
+
+type f = (arg /* comment */) => void;
+
+type f = (?arg) => void;
+
+class X {
+  constructor(
+    ideConnectionFactory: child_process$ChildProcess => FlowIDEConnection =
+        defaultIDEConnectionFactory,
+  ) {
+  }
+}
+
+interface F {
+  ideConnectionFactoryLongLongLong: (child_process$ChildProcess) => FlowIDEConnection
+}
+
+type ExtractType = <A>(B<C>) => D
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+type Banana = {
+  eat: (string) => boolean
+};
+
+type Hex = { n: 0x01 };
+
+type T = { method: (a) => void };
+
+type T = { method(a): void };
+
+declare class X { method(a): void }
+
+declare function f(a): void;
+
+var f: (a) => void;
+
+interface F { m(string): number }
+
+interface F { m: (string) => number }
+
+function f(o: { f: (string) => void }) {}
+
+function f(o: { f(string): void }) {}
+
+type f = (...arg) => void;
+
+type f = (/* comment */ arg) => void;
+
+type f = (arg /* comment */) => void;
+
+type f = (?arg) => void;
+
+class X {
+  constructor(
+    ideConnectionFactory: (child_process$ChildProcess) => FlowIDEConnection = defaultIDEConnectionFactory
+  ) {}
+}
+
+interface F {
+  ideConnectionFactoryLongLongLong: (child_process$ChildProcess) => FlowIDEConnection;
+}
+
+type ExtractType = <A>(B<C>) => D;
+
+`;
diff --git a/tests/flow_function_parentheses/jsfmt.spec.js b/tests/flow_function_parentheses/jsfmt.spec.js
index 425bb9ff4137..d0170fdab72b 100644
--- a/tests/flow_function_parentheses/jsfmt.spec.js
+++ b/tests/flow_function_parentheses/jsfmt.spec.js
@@ -1,2 +1,3 @@
 run_spec(__dirname, ["flow", "babylon"]);
 run_spec(__dirname, ["flow", "babylon"], { trailingComma: "all" });
+run_spec(__dirname, ["flow", "babylon"], { arrowParens: "always" });