ts utility-types 源码解读 aliases-and-guards
https://github.com/piotrwitek/utility-types bigInt需要es2020的支持 Primitive / isPrimitive js原始类型已经判断一个对象的类似是不是原始类型 // js原始类型, 面试常考... export type Primitive = | string | number | bigint | boolean | symbol | null | undefined; function log(msg: Primitive[]) { console.log(...msg); } // log([{ a: 1 }]); // 正常输出log log([1, "1", "a", null, undefined, 12n]); export const isPrimitive = (val: unknown): val is Primitive => { if (val === null || val === undefined) { return true; } switch (typeof val) { case "string": case "number": case "bigint": case "boolean": case "symbol": { return true; } default: return