/** * Casts T to U. * * @internal */ export type Cast = T extends U ? T : U; /** * Makes the T easy to read. */ export type Resolve = { [ K in keyof T ]: T[ K ]; } & unknown; /** * Pushes U to tuple T. * * @internal */ export type Push = [ ...T, U ]; /** * Returns the first type of the tuple. * * @internal */ export type Head = ( ( ...args: T ) => any ) extends ( arg: infer A, ...args: any[] ) => any ? A : never; /** * Removes the first type from the tuple T. * * @internal */ export type Shift = ( ( ...args: T ) => any ) extends ( arg: any, ...args: infer A ) => any ? A : never; /** * Removes the N types from the tuple T. * * @internal */ export type ShiftN = { 0: T, 1: ShiftN, N, Push>, }[ C['length'] extends N ? 0 : 1 ] extends infer A ? Cast : never;