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
arrow-parens crashes when parsing typescript function with generics #12570
Comments
I’m not sure we support generics - I don’t think they are defined in the type annotations spec in ESTree. I wonder if the best solution here would be to make a complimentary rule in typescript-eslint? Let’s see what the rest of the team thinks. |
Maybe we could change the rule to:
I think that some similar refactorings to indirectly avoid problems with typescript code were being accepted before? |
Yes. |
That makes sense to me, particularly if we can do it in a generic way. 👍🏼 |
Do you by any chance have example PR of such refactor I could refer to? I'd like to contribute and seems like its a good starting issue |
That's great! You can find an example here. Please feel free to ask questions here or to stop by our Gitter chat. |
I've created initial PR #12587 with 2 additional test cases that should cover this bug, bug it doesn't get reproduced in the tests, I'm confused now :/ I've even added additional test with following code: const someconst = <T extends Object, TName extends Extract<keyof T, string | number>>() => { return null } so exactly how it is in my case in my repo, and the test still passes on my local, while when I try to run eslint, in fails (As on travis CI)
and yeah, the Any clues what I might be doing wrong in terms of tests? Or my configuration? |
Seems that your configuration is:
And the rule most likely crashes on an arrow function that has block body. |
Nice catch! Yeah, added another 2 test cases, this time with |
Hey, just a followup, had anyone had a chance to take another look at my pull request? I was able to fix the bug |
@matmalkowski It seems that some feedback has been added to your PR. I'd really love to see this merged! |
@DanielSWolf Hey, I'm doing some vacation now, so will get back to fixing the comments probably on this weekend 👍 |
Sounds great! Have a nice remaining vacation! |
Unfortunately, it looks like there wasn't enough interest from the team Thanks for contributing to ESLint and we appreciate your understanding. |
Is there any update on this issue? |
Reopening this since we might be able to solve this on our end in a generic way. |
Unfortunately, it looks like there wasn't enough interest from the team Thanks for contributing to ESLint and we appreciate your understanding. |
Reopening since there's an open PR #12587. |
I'll work on this. |
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using?
@typescript-eslint/parser
Please show your full configuration:
Configuration
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
What did you expect to happen?
What actually happened? Please include the actual, raw output from ESLint.
the arrow-parens rule for above code detects firstTokenOfParam as
<
and that is incorrect. As result of this, later on, when asserting the rule, it does:and it marks the typescript code as breaking the rule settings, so it tries to log the error message, but it will fail, since
getLocation
helper always grabs starting location from params array that in this case is undefined, resulting in crashAre you willing to submit a pull request to fix this bug?
Yeah, I've been looking at the code and with small guidance I could maybe do the fix
The text was updated successfully, but these errors were encountered: