Typescript: Generic that extends a type with a generic

Created on 4 Dec 2015  路  3Comments  路  Source: microsoft/TypeScript

Say I have an interface

interface Applicative<T> {}

Now I want to define a function f that:

  • takes a Function and takes a type U extending an Applicative wrapping any
  • returns an U wrapping Function

My naive attempts were

  function f<U extends Applicative>(fn: Function, a: U<any>): U<Function>

and

  function f<T, U<T> extends Applicative<T>>(fn: Function, a: U<any>): U<Function>

but none is valid

Can we have a Generic extend a type with a generic ?

Duplicate

All 3 comments

No, typescript doesn't have higher-kinded types.

Duplicate of #1213 and probably others.

Duplicate of #1213 and probably others.

Yes it is. This can be closed

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wmaurer picture wmaurer  路  3Comments

zhuravlikjb picture zhuravlikjb  路  3Comments

dlaberge picture dlaberge  路  3Comments

CyrusNajmabadi picture CyrusNajmabadi  路  3Comments

kyasbal-1994 picture kyasbal-1994  路  3Comments