Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print parens in FunctionTypeAnnotation when arrowParens is "always" #3616

Merged
merged 2 commits into from Dec 31, 2017

Conversation

Projects
None yet
3 participants
@duailibe
Copy link
Member

commented Dec 31, 2017

Fixes #3550

See the 2nd commit for the snapshot changes

@@ -3285,6 +3285,9 @@ function printFunctionParams(path, print, options, expandArg, printTypeParams) {
!fun.rest;

if (isFlowShorthandWithOneArg) {
if (options.arrowParens === "always") {

This comment has been minimized.

Copy link
@vjeux

vjeux Dec 31, 2017

Collaborator

I don't think that it's the right fix. This condition is there to --not-- print parenthesis. What happens if you put options.arrowParens !== "always" && at the beginning of isFlowShorthandWithOneArg condition?

This comment has been minimized.

Copy link
@duailibe

duailibe Dec 31, 2017

Author Member
  type f = (?arg) => void;
  
  class X {
    constructor(
-     ideConnectionFactory: (child_process$ChildProcess) => FlowIDEConnection = defaultIDEConnectionFactory
+     ideConnectionFactory: (
+       child_process$ChildProcess
+     ) => FlowIDEConnection = defaultIDEConnectionFactory
    ) {}
  }
  
  interface F {
-   ideConnectionFactoryLongLongLong: (child_process$ChildProcess) => FlowIDEConnection;
+   ideConnectionFactoryLongLongLong: (
+     child_process$ChildProcess
+   ) => FlowIDEConnection;
  }
@vjeux

This comment has been minimized.

Copy link
Collaborator

commented Dec 31, 2017

Ahh yeah... it is the right place then! Thanks for the counter example :)

@vjeux vjeux merged commit 51744e1 into prettier:master Dec 31, 2017

4 checks passed

codecov/patch 100% of diff hit (target 80%)
Details
codecov/project 95.87% (+<.01%) compared to 6c0dd74
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
deploy/netlify Deploy preview ready!
Details

@duailibe duailibe deleted the duailibe:flow-arrow-parens branch Dec 31, 2017

@azz azz added this to the 1.10 milestone Jan 7, 2018

@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.