-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Type for arbitrary number of function parameters of specified types #4338
Comments
Looks like you want something that allows a variable number of parameters with arbitrary types, but then captures them so they can be repeated in another signature. I think you may find a relevant discussion at #3622 (comment) and #3870. |
Do you actually need an infinite number of parameters? If in practice you top out at something like ten or twenty then this might be a good pattern:
It's flexible, doesn't require new syntax, and works today. |
That is indeed the recommended pattern to use today. |
looks like a duplicate of #1773 |
I'd like to have a type for a function which takes in zero or more parameters, and then use the type for the parameters, e.g.
This is useful in e.g. typing the spread function here:
DefinitelyTyped/DefinitelyTyped@3eb67c9
I need to use the
...args: any[]
, which is not quite what I'm looking for.In essence, the type I want to use is
[A?, B?, C?, ...]
, or maybe something likeParams<T>
if such an interface would exist.The text was updated successfully, but these errors were encountered: