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

fix(eslint-plugin): [no-unsafe-argument] handle tuple types on rest arguments #3269

Merged
merged 1 commit into from Apr 6, 2021

Conversation

bradzacher
Copy link
Member

@G-Rath noticed that we were false-reporting on jest expect functions.
Turns out this was because I hadn't handled tuple rest types.

It turns out that generic array rest types are reported by TS as if they were tuples.
So for function foo<T extends any[]>(...param: T): void - param will always report as a tuple.
Eg foo(1, 2, 'a', 1 as any) will report the type of param to be [number, number, string, any]. Which means we can't actually do a check here 😢

@bradzacher bradzacher added the bug Something isn't working label Apr 5, 2021
@typescript-eslint
Copy link
Contributor

Thanks for the PR, @bradzacher!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day.

@codecov
Copy link

codecov bot commented Apr 5, 2021

Codecov Report

Merging #3269 (b8494a7) into master (9238e91) will increase coverage by 0.01%.
The diff coverage is 81.25%.

@@            Coverage Diff             @@
##           master    #3269      +/-   ##
==========================================
+ Coverage   92.80%   92.82%   +0.01%     
==========================================
  Files         318      318              
  Lines       10984    11003      +19     
  Branches     3105     3110       +5     
==========================================
+ Hits        10194    10213      +19     
  Misses        350      350              
  Partials      440      440              
Flag Coverage Δ
unittest 92.82% <81.25%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ages/eslint-plugin/src/rules/no-unsafe-argument.ts 85.22% <81.25%> (+4.06%) ⬆️

@bradzacher bradzacher merged commit 6f8cfe6 into master Apr 6, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 7, 2021
@bradzacher bradzacher deleted the no-unsafe-arg-fix-tuple-rest-args branch August 21, 2021 22:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant