import type { MethodOptions } from '../../options/method.js' import type { UnionToIntersection } from '../../utils/intersect.js' import type { SliceFirst } from '../../utils/slice.js' import type { Plugin, Plugins } from '../shape/main.js' import type { InstanceMethod, InstanceMethods } from './main.js' /** * Bound mixed method parameters */ type ErrorMixedMethodParams< InstanceMethodArg extends InstanceMethod, MethodOptionsArg extends MethodOptions, > = | readonly [unknown, ...SliceFirst>] | ([MethodOptionsArg] extends [never] ? never : readonly [ unknown, ...SliceFirst>, MethodOptionsArg, ]) /** * Bound mixed method of a plugin */ type ErrorMixedMethod< InstanceMethodArg extends InstanceMethod, MethodOptionsArg extends MethodOptions, > = ( ...args: ErrorMixedMethodParams ) => ReturnType /** * Bound mixed methods of a plugin, always defined */ type ErrorMixedMethods< InstanceMethodsArg extends InstanceMethods, MethodOptionsArg extends MethodOptions, > = { readonly [MethodName in keyof InstanceMethodsArg]: ErrorMixedMethod< InstanceMethodsArg[MethodName], MethodOptionsArg > } /** * Bound mixed methods of a plugin, if defined */ type PluginMixedMethods = PluginArg extends { instanceMethods: InstanceMethods } ? ErrorMixedMethods> : object /** * Bound mixed methods of all plugins */ export type PluginsMixedMethods = UnionToIntersection> & {}