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] broken code emitted for type annotation with empty type parameters when the value is an arrow function and arrow-parens: 'avoid' #13817

Closed
bradzacher opened this issue Nov 8, 2022 · 1 comment · Fixed by #14073
Assignees
Labels
lang:flow Issues affecting Flow-specific constructs (not general JS issues) locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:bug Issues identifying ugly output, or a defect in the program

Comments

@bradzacher
Copy link

bradzacher commented Nov 8, 2022

Prettier 2.7.1
Playground link

--parser flow
--arrow-parens avoid
--trailing-comma all

Input:

const xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: xxxxxxxxxxxxxxxxxxxxxx<> =
  arg => null;

Output:

const xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: xxxxxxxxxxxxxxxxxxxxxx<
  ,
> = arg => null;

Expected behavior:

Not-broken code. I'd suggest probably:

const xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: xxxxxxxxxxxxxxxxxxxxxx<> =
  arg => null;
@bradzacher
Copy link
Author

bradzacher commented Nov 8, 2022

It's worth noting that the same code emits correctly for typescript and babel-ts, but not babel, babel-flow, or flow.

However the output for the TS parsers is pretty ugly - it includes an empty line!

const xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: xxxxxxxxxxxxxxxxxxxxxx<

> = arg => null;

@sosukesuzuki sosukesuzuki added type:bug Issues identifying ugly output, or a defect in the program lang:flow Issues affecting Flow-specific constructs (not general JS issues) labels Nov 10, 2022
@fisker fisker self-assigned this Dec 28, 2022
@github-actions github-actions bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Nov 28, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lang:flow Issues affecting Flow-specific constructs (not general JS issues) locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:bug Issues identifying ugly output, or a defect in the program
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants