interface A {
(obj? : any) : any;
func1() : void;
func2() :void;
}
如何编写实现 A 的类 B?我将如何实现参数化构造函数?
最佳答案
根据定义,接口(interface)不能包含构造函数。你必须在你实现的类中移动它:
interface A {
func1(): void;
func2(): void;
}
class B implements A {
constructor(obj? : any) {
}
func1() {
}
func2() {
}
}
关于typescript - 接口(interface) typescript 的实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34536393/