![[捂脸]](http://lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_28.8981538.png)
@每日英语7
Item 7: Think of Types as Sets of Values
- Think of types as sets of values(the type's domain). These sets can either be finite(e.g., boolean or literal types) or infinite(e.g., number or string)
- 思考值设置的类型(类型的有限范围)。这些设置不单可以是有限的(boolean 或者 文字类型)而且可以说无限的(number 或者 string)
- TypeScript types form intersecting sets rather than a strict hierarchy. Two types can overlap without either being a subtype of the other.
- TS 的类型构建与相交的设置而不是严肃的登记制。两种类型可以重叠而不需要一方称为另外一方的子类型
- Remember that an object can still belong to a type even if it has additional properties that were not mentioned in the type declaration
- 记住一个对象仍然属于它之前配置了类型,即便它有了额外的在类型声明中没有被提及的属性
- Type operations apply to a set's domain. The intersection of A and B is the intersection of A's domain and B's domain. For object types, this means that values in A & B have the properties of both A and B
- 类型运行适用于设置的领域。A 和 B 的交集就是 A 领域和 B 领域的交集。对于一个对象类型的值,这意味着这个值在 A & B 类型中,就需要同时拥有 A 和 B 的属性
Item 7: Think of Types as Sets of Values
- Think of types as sets of values(the type's domain). These sets can either be finite(e.g., boolean or literal types) or infinite(e.g., number or string)
- 思考值设置的类型(类型的有限范围)。这些设置不单可以是有限的(boolean 或者 文字类型)而且可以说无限的(number 或者 string)
- TypeScript types form intersecting sets rather than a strict hierarchy. Two types can overlap without either being a subtype of the other.
- TS 的类型构建与相交的设置而不是严肃的登记制。两种类型可以重叠而不需要一方称为另外一方的子类型
- Remember that an object can still belong to a type even if it has additional properties that were not mentioned in the type declaration
- 记住一个对象仍然属于它之前配置了类型,即便它有了额外的在类型声明中没有被提及的属性
- Type operations apply to a set's domain. The intersection of A and B is the intersection of A's domain and B's domain. For object types, this means that values in A & B have the properties of both A and B
- 类型运行适用于设置的领域。A 和 B 的交集就是 A 领域和 B 领域的交集。对于一个对象类型的值,这意味着这个值在 A & B 类型中,就需要同时拥有 A 和 B 的属性
展开
评论
1