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

False-positive of arrow-parens with generic arrow function #344

Closed
mnn opened this issue Jul 23, 2018 · 6 comments · Fixed by #417
Closed

False-positive of arrow-parens with generic arrow function #344

mnn opened this issue Jul 23, 2018 · 6 comments · Fixed by #417

Comments

@mnn
Copy link

mnn commented Jul 23, 2018

const t = <A>(a: A): A => {
    const b = a + 1;
    return b;
};

I am getting:

error Expected parentheses around arrow function argument having a body with curly braces arrow-parens

which doesn't seem right. Applying fix results in invalid code:

const t = (<)A>(a: A): A => {

Workaround is rewrite arrow function to classic function.

@gajus gajus added the bug label Jul 23, 2018
@gajus
Copy link
Owner

gajus commented Jul 23, 2018

Fix would be welcome.

@gajus
Copy link
Owner

gajus commented Jul 18, 2019

🎉 This issue has been resolved in version 3.12.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@Mr-Wallet
Copy link

Still getting this problem on eslint@6.8.0 and eslint-plugin-flowtype@4.7.0.

@gajus gajus reopened this Jul 16, 2020
@gajus
Copy link
Owner

gajus commented Jul 16, 2020

Please raise a PR with a broken test case.

@gajus gajus closed this as completed Jul 16, 2020
@Mr-Wallet
Copy link

Mr-Wallet commented Jul 21, 2020

@gajus Question about writing tests: is the assumption that we always be targeting the latest version of flow, and changes to the Flow API are supposed to be handled in future PRs? I don't see any way to target specific versions of flow.

After 90 minutes, I'm totally at a loss of how to reproduce the error in the tests. I've ruled out an interaction with other plugins in my own project, and I've copy-pasted a few examples that fail in my project and it doesn't show an error in the tests. The issue only comes up when defining functions that use Generics, and usually only when those functions are defined as arguments to other functions. Using the function keyword instead of arrow functions is a reasonable work-around (we don't use this very much in our code base).

I'm prepared to leave this for now and move on to other things. But if you happen have any advice for why the tests might have different results than an actual project, I would be eager to try some more experiments to try and nail down why this is happening.

@gajus
Copy link
Owner

gajus commented Jul 22, 2020

@gajus Question about writing tests: is the assumption that we always be targeting the latest version of flow, and changes to the Flow API are supposed to be handled in future PRs? I don't see any way to target specific versions of flow.

That is correct.

I'm prepared to leave this for now and move on to other things. But if you happen have any advice for why the tests might have different results than an actual project, I would be eager to try some more experiments to try and nail down why this is happening.

If you can produce a minimal repository for replicating the issue, that would be enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants