We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
declare function compose<T, U, V>(a: (x: T) => U, b: (y: U) => V): (x: )
Works fine today if you pass it in non-generic functions, but not for if you pass in generic functions.
However, gives bad results today for a generic function.
Ideally, you'd like to be able to use compose on higher-order functions like the following:
declare function compose<T, U, V>(a: (x: T) => U, b: (y: U) => V): (x: T) => V; declare function arrayToList<T>(x: Array<T>): List<T>; declare function box<U>(x: U): { value: U }; compose(arrayToList, box) // <T>(x: Array<T>) => { value: List<T> }
Idea: you want to float out the free type variables into the result type for whatever doesn't get unified.
You want to build up the inferences:
declare function compose<A, B, C>(a: (x: A) => B, b: (y: B) => C): (x: A) => C; declare function arrayToList<T>(x: Array<T>): List<T>; declare function box<U>(x: U): { value: U }; compose(arrayToList, box); // A = Array<T> // B = List<T> // B = U // C = { value: U }
You iterate on A, B, and C, finding new "truths" about the relationships between these type variables. For example, you can see that:
A
B
C
U = List<T>
and then
C = { value: List<T> }
But there are questions: how do you
#26042
type Parameters<T extends (...args: (infer U)) => any> = U;
#23911
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Thoughts about unification
Works fine today if you pass it in non-generic functions, but not for if you pass in generic functions.
However, gives bad results today for a generic function.
Ideally, you'd like to be able to use compose on higher-order functions like the following:
Idea: you want to float out the free type variables into the result type for whatever doesn't get unified.
You want to build up the inferences:
You iterate on
A
,B
, andC
, finding new "truths" about the relationships between these type variables. For example, you can see that:and then
But there are questions: how do you
Parameters type aliases
#26042
Method parameter inference
#23911
The text was updated successfully, but these errors were encountered: