[英]typescript: get the type of basic class in interface
我有一个基础课,就像
class Animal {
}
我有两个孩子班
class Dog extends Animal {}
class Bird extends Animal {}
现在,我想定义一个包含Animal类的接口,例如
interface Zoo{
name: string;
animal: Animal;
}
并使用它
const myZoo: Zoo = {
name: 'zooName',
animal: Dog // problem is here
}
顺其自然,我失败了。 所以我该怎么做? 谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.