类型

记录TypeScript常用类型操作

const a = ['a', 'b'] as const 
const b: typeof a[number] = 'a'

type DeepPartial<T> = {
  [P in keyof T]?: T[P] extends Array<infer I>
    ? Array<DeepPartial<I>>
    : DeepPartial<T[P]>
}

type Unpack<T extends (...args: any[]) => void> = Extract<Awaited<ReturnType<T>>, [unknown, null]>[0]

最后更新于