type HookCallback = (...arguments_: any) => Promise | void; interface Hooks { [key: string]: HookCallback; } type HookKeys = keyof T & string; type DeprecatedHook = { message?: string; to: HookKeys; }; type DeprecatedHooks = { [name in HookKeys]: DeprecatedHook; }; type ValueOf = C extends Record ? C[keyof C] : never; type Strings = Exclude; type KnownKeys = keyof { [K in keyof T as string extends K ? never : number extends K ? never : K]: never; }; type StripGeneric = Pick extends keyof T ? KnownKeys : never>; type OnlyGeneric = Omit extends keyof T ? KnownKeys : never>; type Namespaces = ValueOf<{ [key in Strings]: key extends `${infer Namespace}:${string}` ? Namespace : never; }>; type BareHooks = ValueOf<{ [key in Strings]: key extends `${string}:${string}` ? never : key; }>; type HooksInNamespace = ValueOf<{ [key in Strings]: key extends `${Namespace}:${infer HookName}` ? HookName : never; }>; type WithoutNamespace = { [key in HooksInNamespace]: `${Namespace}:${key}` extends keyof T ? T[`${Namespace}:${key}`] : never; }; type NestedHooks = (Partial> | Partial>) & Partial<{ [key in Namespaces>]: NestedHooks>; }> & Partial<{ [key in BareHooks>]: T[key]; }>; type InferCallback = HT[HN] extends HookCallback ? HT[HN] : never; type InferSpyEvent> = { [key in keyof HT]: { name: key; args: Parameters; context: Record; }; }[keyof HT]; declare class Hookable = Record, HookNameT extends HookKeys = HookKeys> { private _hooks; private _before?; private _after?; private _deprecatedHooks; private _deprecatedMessages?; constructor(); hook(name: NameT, function_: InferCallback, options?: { allowDeprecated?: boolean; }): () => void; hookOnce(name: NameT, function_: InferCallback): () => void; removeHook(name: NameT, function_: InferCallback): void; deprecateHook(name: NameT, deprecated: HookKeys | DeprecatedHook): void; deprecateHooks(deprecatedHooks: Partial>>): void; addHooks(configHooks: NestedHooks): () => void; removeHooks(configHooks: NestedHooks): void; removeAllHooks(): void; callHook(name: NameT, ...arguments_: Parameters>): Promise; callHookParallel(name: NameT, ...arguments_: Parameters>): Promise; callHookWith>) => any>(caller: CallFunction, name: NameT, ...arguments_: Parameters>): ReturnType; beforeEach(function_: (event: InferSpyEvent) => void): () => void; afterEach(function_: (event: InferSpyEvent) => void): () => void; } declare function createHooks>(): Hookable; declare function flatHooks(configHooks: NestedHooks, hooks?: T, parentName?: string): T; declare function mergeHooks(...hooks: NestedHooks[]): T; declare function serial(tasks: T[], function_: (task: T) => Promise | any): Promise; /** @deprecated */ declare function serialCaller(hooks: HookCallback[], arguments_?: any[]): Promise; /** @deprecated */ declare function parallelCaller(hooks: HookCallback[], args?: any[]): Promise; interface CreateDebuggerOptions { /** An optional tag to prefix console logs with */ tag?: string; /** * Show hook params to the console output * * Enabled for browsers by default */ inspect?: boolean; /** * Use group/groupEnd wrapper around logs happening during a specific hook * * Enabled for browsers by default */ group?: boolean; /** Filter which hooks to enable debugger for. Can be a string prefix or fn. */ filter?: string | ((event: string) => boolean); } /** Start debugging hook names and timing in console */ declare function createDebugger(hooks: Hookable, _options?: CreateDebuggerOptions): { /** Stop debugging and remove listeners */ close: () => void; }; export { CreateDebuggerOptions, DeprecatedHook, DeprecatedHooks, HookCallback, HookKeys, Hookable, Hooks, NestedHooks, createDebugger, createHooks, flatHooks, mergeHooks, parallelCaller, serial, serialCaller };