-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Ability to pass a generic function as a parameter to a generic function - (perhaps the best way to implement "oneof") #56746
Comments
Note that declare const y: <T>(a: T, b: T) => T;
y(1, ""); // this is an error today Of course,
This sounds like you want higher-kinded types, for which there are a number of open issues; #1213 is probably the closest to canonical. |
It could be that 1213 is superset of this proposal, at least in terms of satisfying all the desired results describable as "Allow classes to be parametric in other parametric classes". Conversely, proposal 1213 doesn't mention usability in conditional generic expressions which is the application described here. Of course those differing applications should ultimately converge anyway. However, it is possible that beginning development with one target or the other would differ in what functionality became available first - i.e., that getting one working wouldn't guarantee the other worked right away without further development. As for the way the generic function parameters are specified in 1213 - e.g.,
For example
Then, when
is defined, the evaluation is going to be very close to I suppose all differences from 1213 could be classified as implementation details, and therefore this really is a duplicate. |
All right, I'll close this and post a comment at the end of #1213 instead. |
π Search Terms
β Viability Checklist
β Suggestion
Here is an implementation for "oneof" (c.f. #27808) for an example generic function
GenFunc
The text was updated successfully, but these errors were encountered: