-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 does not factor in generics or overloads #43731
Comments
This is a known design limitation. |
Thanks for clarifying. Bummer that it isn't supported yet. Are there any plans to support this? I can't see anything about it in the roadmap at the moment. |
I haven't seen any mention regarding this by the TypeScript team, so I wouldn't get my hopes up. |
I'd actually still want to add to this that generics are also not supported since they all get converted to Here is the same playground, but without the overloads: Playground |
Because |
Bug Report
🔎 Search Terms
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
The
Parameters
type seems to choose either the last or a random overload of the given method instead of all of them. Also doesn't factor in generics and converts them tounknown
instead.Even if it would return what I would have expected (see
Expected
type in example), it still isn't usable in practice.🙂 Expected behavior
That
Args
would result in something similar toExpected
. All of the overloads should be factored in and also generics.The
Expected
args should be usable onfoo
.Real-world usages
Any wrapper function where the original function is complex, has overloads or is generic. In our case, it's everything :)
More specifically I want to reduce boilerplating with
@ngrx
so I wanted to wrap the functioncreateSelector
which is declared here, which is similar to thefoo
of my example, but with 31 overloads instead of only 2 and where the return type is dependent on the parameters (theproject
argument).Wrapping this method is possible, but requires just an insane amount of copy-pasting with some little changes which isn't feasible and does not exactly help in reducing the amount of code.
The text was updated successfully, but these errors were encountered: