TypeScript 常用类型
ReturnType
Awaited
InstanceType
Parameters
Omit, Exclude, Extract, Pick
Required 字段全部转成必须,Partial 相反
构造函数类型
closestElementabstract new (...args: any) => any>(constructor: K): InstanceType | null;
让编辑器有提示:type LiteralType = 'cat' | 'dog' | (string & {})
type ElementOf = T extends (infer E)[] ? E : never
type Json = null | boolean | number | string | Json[] | { [prop: string]: Json }
const list = ['a', 'b', 'c'] as const; // TS3.4 syntax
type NeededUnionType = typeof list[number]; // 'a'|'b'|'c';