Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify generic type as a generic (higher kinded types)

Tags:

typescript

In Typescript, is it possible to specify a generic type as generic? Specifically, I would like to be able to define a function signature as follows:

function events<T>(): T<Event>

However I am receiving the following error from the typescript compiler:

[ts] Type 'T' is not generic.
like image 590
Wayne Maurer Avatar asked May 19 '16 12:05

Wayne Maurer


1 Answers

"generic type as a generic": if I understand correctly what you are trying to achieve is to use higher kinded types.

This not (yet) possible in Typescript: see this

like image 51
Bruno Grieder Avatar answered Oct 13 '22 19:10

Bruno Grieder