export type Prettify = { [K in keyof T]: T[K] } & {} export type UnionToIntersection = ( U extends any ? (k: U) => void : never ) extends (k: infer I) => void ? I : never // make keys required but keep undefined values export type LooseRequired = { [P in keyof (T & Required)]: T[P] } // If the type T accepts type "any", output type Y, otherwise output type N. // https://stackoverflow.com/questions/49927523/disallow-call-with-any/49928360#49928360 export type IfAny = 0 extends 1 & T ? Y : N export type IsKeyValues = IfAny< T, false, T extends object ? (keyof T extends K ? true : false) : false > /** * Utility for extracting the parameters from a function overload (for typed emits) * https://github.com/microsoft/TypeScript/issues/32164#issuecomment-1146737709 */ export type OverloadParameters any> = Parameters< OverloadUnion > type OverloadProps = Pick type OverloadUnionRecursive< TOverload, TPartialOverload = unknown, > = TOverload extends (...args: infer TArgs) => infer TReturn ? TPartialOverload extends TOverload ? never : | OverloadUnionRecursive< TPartialOverload & TOverload, TPartialOverload & ((...args: TArgs) => TReturn) & OverloadProps > | ((...args: TArgs) => TReturn) : never type OverloadUnion any> = Exclude< OverloadUnionRecursive<(() => never) & TOverload>, TOverload extends () => never ? never : () => never >