declare module "before-after-hook" { export interface HookCollection { /** * Invoke before and after hooks. */ (name: string | string[], method: (options: any) => Promise | any): Promise /** * Invoke before and after hooks. */ (name: string | string[], options: any, method: (options: any) => Promise | any): Promise /** * Add before hook for given name. Returns `hook` instance for chaining. */ before (name: string, method: (options: any) => Promise | any): HookCollection /** * Add error hook for given name. Returns `hook` instance for chaining. */ error (name: string, method: (options: any) => Promise | any): HookCollection /** * Add after hook for given name. Returns `hook` instance for chaining. */ after (name: string, method: (options: any) => Promise | any): HookCollection /** * Add wrap hook for given name. Returns `hook` instance for chaining. */ wrap (name: string, method: (options: any) => Promise | any): HookCollection /** * Removes hook for given name. Returns `hook` instance for chaining. */ remove (name: string, beforeHookMethod: (options: any) => Promise | any): HookCollection } export interface HookSingular { /** * Invoke before and after hooks without options */ (method: (options: T) => T | null | void): Promise /** * Invoke before and after hooks without options */ (method: (options: T) => Promise): Promise /** * Invoke before and after hooks with options */ (options: T, method: (options: T) => T | null | void): Promise /** * Invoke before and after hooks with options */ (options: T, method: (options: T) => Promise): Promise /** * Add before hook. Returns `UnnamedHook` instance for chaining. */ before( beforeFn: (options: T) => T | null | void ): HookSingular; /** * Add before hook. Returns `UnnamedHook` instance for chaining. */ before( beforeFn: (options: T) => Promise ): HookSingular; /** * Add error hook. Returns `UnnamedHook` instance for chaining. */ error( errorFn: (options: T) => T | null | void ): HookSingular; /** * Add error hook. Returns `UnnamedHook` instance for chaining. */ error( errorFn: (options: T) => Promise ): HookSingular; /** * Add after hook. Returns `UnnamedHook` instance for chaining. */ after( afterFn: (options: T) => T | null | void ): HookSingular; /** * Add after hook. Returns `UnnamedHook` instance for chaining. */ after( afterFn: (options: T) => Promise ): HookSingular; /** * Add wrap hook. Returns `UnnamedHook` instance for chaining. */ wrap( wrapFn: (options: T) => T | null | void ): HookSingular; /** * Add wrap hook. Returns `UnnamedHook` instance for chaining. */ wrap( wrapFn: (options: T) => Promise ): HookSingular; /** * Removes hook. Returns `UnnamedHook` instance for chaining. */ remove( beforeHookMethod: (options: T) => T | null | void ): HookSingular; /** * Removes hook. Returns `UnnamedHook` instance for chaining. */ remove( beforeHookMethod: (options: T) => Promise ): HookSingular; } export const Hook: { new (): HookCollection /** * Creates a nameless hook that allows passing down typings for the options */ Singular: {new (): HookSingular} /** * Creates a hook collection */ Collection: {new (): HookCollection} } export const Singular: {new (): HookSingular} export const Collection: {new (): HookCollection} export = Hook }