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

fwanicka picture fwanicka  ·  3Comments

Antony-Jones picture Antony-Jones  ·  3Comments

uber5001 picture uber5001  ·  3Comments

MartynasZilinskas picture MartynasZilinskas  ·  3Comments

dlaberge picture dlaberge  ·  3Comments