热心青年小邓 2021-04-16 17:36 采纳率: 90.9%
浏览 32
已采纳

typescript索引

class Animal {

  name: string;

}

class Dog extends Animal {

 breed: string;

}

// 错误:使用数值型的字符串索引,有时会得到完全不同的Animal!

interface NotOkay {

  [x: number]: Animal;

  [x: string]: Dog;

}

这段代码代表什么意思?

ts初学者,望各位大佬多多指导

  • 写回答

2条回答 默认 最新

  • 波塞冬的祝福 2021-04-16 17:44
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?