Request no-any rule to ignore rest args #4437
Comments
Hi @jedmao! TS 3 added variadic rest arg types, so in theory you should be able to work around the restriction of type Func<T extends any[]> = (...args: T) => void;
let listener: Func<[string, number]> = (one: string, two: number) => { /* ... */ }; Does that solve your use case? |
@JoshuaKGoldberg I'm not sure how that solves the problem, as it still uses |
It looks like the following might work: public emit(eventName: string, ...rest: Array<unknown>) { |
I take that back. This is still an issue. |
I agree, I think this rule should be lenient (by default) about |
Hi, I am new to the open source community and this is my first PR. I thought this would be a good first issue to work on and I would love to receive some feedback. |
Fixed super cleanly in #4581! 💪 |
Feature request
Is your feature request related to a problem? Please describe.
Using the
no-any
rule, I get frustrated when destructuring...rest
args:In this case, the
emit
method is going to call an internal listener withlistener(...rest)
. I don't care what the types are. I just want to pass-through the...rest
args to the listener. I run into this issue quite frequently.It would be great if I didn't have to scatter
// tslint:disable-next-line:no-any
everywhere I need...rest
args.Describe the solution you'd like
Describe alternatives you've considered
I considered using generics, but it's too limiting:
That would force the
...rest
args to have all of the same type. If the first...rest
arg was astring
, it would force all the rest to bestring
as well.Additional context
The text was updated successfully, but these errors were encountered: