获得徽章 8
厨猿加加的头像
关注了
熊的猫
VIP.5 如鱼得水
打工人中最会做饭的厨子 @ ByteDance
厨猿加加的头像
打工人中最会做饭的厨子 @ ByteDance
厨猿加加的头像
关注了
zxg_神说要有光
VIP.5 如鱼得水
打工人中最会做饭的厨子 @ ByteDance
厨猿加加的头像
打工人中最会做饭的厨子 @ ByteDance
厨猿加加的头像
打工人中最会做饭的厨子 @ ByteDance
厨猿加加的头像
打工人中最会做饭的厨子 @ ByteDance
厨猿加加的头像
关注了
速冻鱼
VIP.4 融会贯通
打工人中最会做饭的厨子 @ ByteDance
@每日英语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 的属性
展开
评论
@每日英语6

Item6: Use Your Editor to Interrogate and Explore the Type System

- Take advantage of the Typescript language services by using an editor that can use them.
- 通过使用编辑器在 TS 语言系统中获取优势,编辑器可以使用 TS 语言系统;
- Use your editor to build an intuition for how the type system works and how Typescript infers types.
- 使用你的编辑器去构建一个直觉,类型是怎么样运行的,TS 怎样推断出类型的。
- Know how to jump into type declaration files to see how they model behavior
- 知道怎么条件类型断言文件去查看它们如何塑造行为。
展开
评论
@每日英语5
Limit Use of the any type

The any type effectively silences the type checker and Typescript language services. It can mask real problems, harm developer experience, and undermine confidence in the type system. Avoid using it when you can!
展开
评论
下一页
个人成就
文章被点赞 329
文章被阅读 37,243
掘力值 2,494
收藏集
3
关注标签
24
加入于