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

Popular posts from this blog

node.js - NodeJS remote terminal to Dropbear OpenWRT-Server -

Qt4: how to send QString inside a struct via QSharedMemory -

node.js - On Gitbash - Bower : ENOGIT git is not installed or not in the PATH -