-
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
Parameters<typeof someFunction> does not preserve type constraint or parameter inference. #54014
Comments
This would first require implementing a new kind of a generic type that would have its type parameter(s) inferred on assignment, as well as the ability for type aliases to directly accept and return generic types (HKT). Neither of these are possible with the current type system. |
Thanks @fatcerberus for linking the other issues. |
I'm going to reopen this, because even if those other suggestions are implemented, Parameters will probably still be unconstrained. |
To expedite the triage process, we need everyone to follow the issue template and instructions. When you clicked "Create New Issue", the issue form was pre-populated with a template and some instructions. We need you to read those instructions completely, follow them, and then fill in all the fields in that template. We are not able to assist with issues that don't follow the template instructions as they represent a significantly larger amount of work compared to issues which are correctly specified. Thank you for understanding. |
Given the following two types.
The following function is able to correctly constrain the type of the second parameter given the following function declaration and call.
However, this constraint is not preserved in the
Parameters
utility type.At least not until the generic is explicitly set.
Ultimately, the desired functionality is to have types obtain the same type inference as functions without a runtime requirement to keep the typing/code dry.
Playground link
The text was updated successfully, but these errors were encountered: