1️⃣ 类型推演

根据已知的类型,推演出新的类型

2️⃣ typeof

TS 中的 typeof,书写在位置的类型约束位置上。
表示:获取数据的原始类型。

  1. const a: typeof a = 'aaa'
  2. let b: typeof a

当 typeof 作用与类的时候,typeof 表示类本身

2️⃣ keyop

作用与类,接口,类型别名,用于获取其他类型中所有成员名组成的联合类型
image.png

2️⃣ in

该关键字往往和 keyof 连用,限制某个索引类型的取值范围。
image.png

1️⃣ 预设的类型演算

2️⃣ Partial

将类型 T 中的成员变为可选
image.png

2️⃣ Required

将类型 T 中的成员变为必填

2️⃣ Readonly

将类型 T 中的成员变为只读

2️⃣ Exclude

从类型 T 中剔除可以赋值给 U 的类型
image.png

2️⃣ Extract

提取 T 中可以赋值给 U 的类型
image.png

2️⃣ NonNullable

从 T 中剔除 null 和 undefined
image.png

2️⃣ ReturnType

获取函数返回值类型
image.png

2️⃣ InstanceType

获取构造函数类型的实例类型