/** * Utility types for type manipulation */ /** * Check if type is `any` */ export type IsAny = 0 extends 1 & T ? true : false /** * Check if type is `never` */ export type IsNever = [T] extends [never] ? true : false /** * Check if type is `unknown` */ export type IsUnknown = IsAny extends true ? false : unknown extends T ? true : false /** * Simplify a type by expanding it */ export type Simplify = { [K in keyof T]: T[K] } & {} /** * Make all properties optional deeply */ export type DeepPartial = T extends object ? { [P in keyof T]?: DeepPartial } : T /** * Get keys that have non-never values */ export type NonNeverKeys = { [K in keyof T]: IsNever extends true ? never : K }[keyof T] /** * Remove never values from object type */ export type OmitNever = Pick> /** * Converts an empty object or undefined to void, making function arguments optional. * * @example * ```ts * // value is marked as required, but "void" makes it optional. * function myFunction(value: void | number) { * return value * } * * // Both are valid calls. * myFunction() * myFunction(1) * ``` */ // biome-ignore lint/complexity/noBannedTypes: {} check is standard pattern for empty object detection export type EmptyToVoid = {} extends T ? void | T : undefined extends T ? void | T : T