我有一个基本类(class),就像
class Animal {
}
我有两个子类,例如
class Dog extends Animal {}
class Bird extends Animal {}
现在,我想定义一个包含 Animal 类的接口(interface),例如
interface Zoo{
name: string;
animal: Animal;
}
并使用它
const myZoo: Zoo = {
name: 'zooName',
animal: Dog // problem is here
}
算了,我失败了。所以我该怎么做?谢谢。
最佳答案
关于javascript - typescript:获取接口(interface)中基本类的类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47922001/