扩展其类型参数的泛型类

时间:2016-10-21 16:47:49

标签: typescript

在TypeScript 2.x中,是否可以使用class extends通用/参数class C<T implements I> extends T {}自己的类型参数?

interface ConnectionImpl { connect(address): Promise<ConnectionImpl> } class HTTPConnection implements ConnectionImpl { connect(url: string): Promise<HTTPConnection> { ... } } class Connecton<T implements ConnectionImpl> extends T { constructor(private address) {} handshake(key: number): Promise<Token> { return this.connect(this.address) .then(...) } } let conn = new Connection<HTTPConnection>("...")

这样的东西

我想要更详细地实现的目标:

{{1}}

0 个答案:

没有答案