generics - TypeScript type parameter to implement multiple interfaces -
in c#, can this:
class dictionary<tkey, tval> tkey : icomparable, ienumerable { }
is there way in typescript 1.5 beta type parameter in generic class or function implement multiple interfaces, without creating entirely new interface purpose?
the obvious way not working due ambiguity of commas.
class dictionary<tkey extends icomparable, ienumerable, tvalue> { }
by way, funnily enough, extends
can handle interface unions fine in generics:
class dictionary<tkey extends icomparable|ienumerable, tvalue> { }
intersection types here since ts 1.6 , can use in above example:
class dictionary<tkey extends icomparable & ienumerable, tvalue> { }
Comments
Post a Comment