Say I have an interface:
interface Applicative<T> {}
Now I want to define a function f
that:
How do I define this in Typescript? I tried the following but it's not valid:
function f<U extends Applicative>(fn: Function, a: U<any>): U<Function>
Unfortunately, typescript does not yet implement higher kinded types.
See microsoft/typescript#1213 - Allow classes to be parametric in other parametric classes for more details.
Though you may find this approach helpful for a workaround: microsoft/typescript#40928 Using this-type with intersection type makes it possible to simulate HKT