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

Flow generic comment formatted incorrectly #4295

Closed
helixbass opened this issue Apr 10, 2018 · 2 comments
Closed

Flow generic comment formatted incorrectly #4295

helixbass opened this issue Apr 10, 2018 · 2 comments
Labels
area:comments Issues with how Prettier prints comments area:flow comment types lang:flow Issues affecting Flow-specific constructs (not general JS issues) type:bug Issues identifying ugly output, or a defect in the program

Comments

@helixbass
Copy link
Contributor

Prettier 1.11.1
Playground link

Input:

const identity = function/*::<T>*/(value/*: T */)/*: T */ {
  return value;
};

Output:

const identity = function(/*::<T>*/ value /*: T */) /*: T */ {
  return value;
};

Expected behavior:
It seems as though the generic comment /*::<T>*/ needs to remain between the function keyword and the ( in order for the Flow parser to correctly recognize the comment (pasting Prettier's output into https://flow.org/try gives errors). Not sure if there is a corresponding case for arrow functions or not

@j-f1 j-f1 added type:bug Issues identifying ugly output, or a defect in the program area:comments Issues with how Prettier prints comments lang:flow Issues affecting Flow-specific constructs (not general JS issues) labels Apr 10, 2018
@helixbass
Copy link
Contributor Author

Here are two other Flow comment syntaxes that seem not to be formatted correctly (ie in such a way that Flow will still parse them):

const x = ([1, 2, 3]/*: Array<number> */);

gets formatted as:

const x = [1, 2, 3]; /*: Array<number> */

and this:

([1, 2, 3]/*: Array<number> */);

gets formatted as:

[1, 2, 3] /*: Array<number> */;

Basically both need to preserve the surrounding parens

@thorn0
Copy link
Member

thorn0 commented Oct 24, 2022

Not an issue anymore because support for Flow comments was removed in #13687

@thorn0 thorn0 closed this as completed Oct 24, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area:comments Issues with how Prettier prints comments area:flow comment types lang:flow Issues affecting Flow-specific constructs (not general JS issues) type:bug Issues identifying ugly output, or a defect in the program
Projects
None yet
Development

No branches or pull requests

3 participants