【发布时间】:2017-11-16 12:09:06
【问题描述】:
是否可以像接口中的类型一样使用 Class ?例如,我有一个类 Animal,我可以使用类似的东西:
interface I {
object: Animal
}
我在这种情况下遇到了错误:
class A {
public static foo(text: string): string {
return text;
}
}
interface IA {
testProp: A;
otherProp: any;
}
class B {
constructor(prop: IA) {
console.log(prop.otherProp);
console.log(prop.testProp.foo('hello!'));
}
}
TS2339:类型“A”上不存在属性“foo”
【问题讨论】:
标签: class typescript types interface