union types 联合类型
type CanCross = "green" | "orange";
type ShouldStop = "orange" | "red";
let canCross = "orange" as CanCross; // ✅
let shouldStop = "orange" as ShouldStop; // ✅
unknow 类型,是所有类型的父集
let something: unknown;
something = "Hello"; // ✅
something = 2; // ✅
something = { name: "Alice" }; // ✅
something = () => "?"; // ✅
A | unknown = unknown
A & unknown = A
交集,对象的交集就是包含2个对象中的所有类型
never类型,string & number = never
A | never = A
A & never = never
any类型,TS最差实践,是所有类型的父集,也是所有类型的子集
A | any = any
A & any = any