【发布时间】:2015-10-08 00:55:44
【问题描述】:
在 C# 中,我可以这样做:
class Dictionary<TKey, TVal> where TKey : IComparable, IEnumerable { }
在 TypeScript 1.5 beta 中有没有办法让泛型类或函数中的类型参数实现多个接口,而无需为此创建全新的接口?
由于逗号的歧义,显而易见的方法显然不起作用。
class Dictionary<TKey extends IComparable, IEnumerable, TValue> { }
顺便说一句,有趣的是,extends 在泛型中可以完美处理接口联合:
class Dictionary<TKey extends IComparable|IEnumerable, TValue> { }
【问题讨论】:
标签: generics interface typescript typescript1.5