question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Comment types of Flow makes Prettier confused

See original GitHub issue

Prettier 1.15.1

Sorry, I could not reproduce it on v1.15.2 playground. 🙇 (solved at 1.15.2 ? 👀) Playground link

In flow, I can typecast with the following, not type-assertion.

Input:

type Props = {|
  ...$Exact<PropsWithTFn>,
  ...$Exact<$Call<typeof mapStateToProps, *, *>>,
  ...$Exact<$Call<typeof mapDispatch, *, *>>,
  ...$Exact<withResponse.WithQueryProps<RootQuery>>,
|};

However, this gets error message below in prettier 1.15.1

Replace `<$Call<typeof·mapDispatch,·*,·*>>` with `/*::·<$Call/*::·<typeof·mapDispatch,·*,·*>·*/>·*/`

Output:

type Props = {|
  ...$Exact<PropsWithTFn>,
  ...$Exact/*:: <$Call/*:: <typeof·mapStateToProps, *, *>*/> */
  ...$Exact/*:: <$Call/*:: <typeof mapDispatch, *, *>*/> */,
  ...$Exact/*:: <withResponse.WithQueryProps<RootQuery>*/> */,
|};

Expected behavior:

type Props = {|
  ...$Exact<PropsWithTFn>,
  ...$Exact<$Call<typeof mapStateToProps, *, *>>,
  ...$Exact<$Call<typeof mapDispatch, *, *>>,
  ...$Exact<withResponse.WithQueryProps<RootQuery>>,
|};

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
ikatyangcommented, Nov 13, 2018

@j-f1 There’re two bugs in the example:

  • /* :: (user.__typename: empty); */ -> (user.__typename: empty);
    • this is the long-standing one
  • ...$Exact<PropsWithTFn>, -> ...$Exact/*:: <PropsWithTFn> */,
    • this one is somehow caused by /* :: (user.__typename: empty); */, it works fine if there’s no /* :: (user.__typename: empty); */
1reaction
j-f1commented, Feb 21, 2019

would you allow me to attempt fixing the issue?

Please go ahead! We appreciate PRs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Options - Prettier
Note that Prettier never unquotes numeric property names in Angular expressions, TypeScript, and Flow because the distinction between string and numeric keys ...
Read more >
Code Quality Tooling with Prettier and ESLint - Wes Bos
json , create one running the command npm init by typing it into the terminal (make sure you are in the beginner-javascript folder)....
Read more >
What is the difference between flow and eslint in react-native ...
Flow is a static type checker for your JavaScript code. It does a lot of work to make you more productive. Making you...
Read more >
Comment Types - JavaScript. Flow
These comments allow Flow to work in plain JavaScript files without any additional work. Comment types syntax. There are two primary pieces of...
Read more >
What is a Pronoun? Types of Pronouns & Examples
Using pronouns helps the flow of sentences and makes them more interesting ... Your reader would be confused and wonder who she is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found