typescript里 泛型中 & 是什么意思 ?
Intersection Types
An intersection type combines multiple types into one. This allows you to add together existing types to get a single type that has all the features you need. For example, > Person & Serializable & Loggable is a > Person and > Serializable and > Loggable. That means an object of this type will have all members of all three types.
表示这个变量同时拥有所有类型所需要的成员,可以作为其中任何一个类型使用。
interface中的extends
// 生物体的接口interface Creature {name: string;}// 动物接口 继承生物接口interface Animal extends Creature {// 自己拥有的属性 actionaction(): void;}
一个接口可以继承多个接口
// 生物体的接口interface Creature {name: string;}// 动物接口interface Animal {// 自己拥有的属性 actionaction(): void;}// 狗Dog接口继承 生物Creature 和 Animal 多继承interface Dog extends Creature, Animal{color: string;}
