/** * TypeScript 类型计算相关 utils * * @module sodash:types */ /** * 提取 Promise 将 resolve 的值的类型. * * @example `PromiseOf> => number` */ export type PromiseOf

= P extends Promise ? A : P /** * 将数组类型的第一个成员去掉, 将剩下的成员作为一个新的数组类型返回. * * @example `Tail<[number, string, boolean]> => [string, boolean]` */ export type Tail = (( ...args: Tuple ) => any) extends (_: any, ..._1: infer Rest) => any ? Rest : never /** * 将类型中的指定字段设置为 required。 * * @example * ```typescript * type T = { a?: number, b?: string, c?: boolean } * type S = RequireProps // => { a?: number, b: string, c: boolean } * ``` */ export type RequireProps = T & Required> /** * 字典类型, { [key: string]: T } 的快捷方式 */ export interface Dictionary { [key: string]: T }