在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}}