UNPKG

renovate

Version:

Automated dependency updates. Flexible so you don't need to be.

27 lines (26 loc) 878 B
export type Handler<T> = (parameters: DecoratorParameters<T>) => Promise<unknown>; export type Method<T> = (this: T, ...args: any[]) => Promise<any>; export type Decorator<T> = <U extends T>(target: U, key: keyof U, descriptor: TypedPropertyDescriptor<Method<T>>) => TypedPropertyDescriptor<Method<T>>; export interface DecoratorParameters<T, U extends any[] = any[]> { /** * Current call arguments. */ args: U; /** * A callback to call the decorated method with the current arguments. */ callback(this: void): unknown; /** * Current call context. */ instance: T; /** * The decorated method name. */ methodName?: string; } /** * Applies decorating function to intercept decorated method calls. * @param fn - The decorating function. */ export declare function decorate<T>(fn: Handler<T>): Decorator<T>;