import { Constructor, PropertiesOfType } from './type-helpers'; /** * Allows you to easily hook into / extend a method on a class. * * ```ts * class Foo { * bar(hello: string): boolean { * return true; * } * } * * patchMethod(Foo, 'bar', function(superMethod, hello) { * console.log('Do something here.'); * return superMethod(hello); * }); * ``` * * @param klass The class to hook into. * @param methodName The name of the method on the class to hook into. * @param fn The hook to execute. * @param fallback A fallback function to be called in case the original super method does not exist. */ export declare function patchMethod, Instance extends InstanceType, K extends PropertiesOfType, SuperMethod extends Extract>(klass: Class, methodName: K, fn: (this: Instance, superMethod: SuperMethod, ...args: Parameters) => ReturnType, fallback?: (this: Instance, ...args: Parameters) => ReturnType): Class; export default patchMethod; /** * Executes the hook before the super method is executed. * * ```ts * class Foo { * bar(hello: string): boolean { * return true; * } * } * * beforeMethod(Foo, 'bar', function(hello) { * console.log('Do something here.'); * }); * ``` * * @param klass The class to hook into. * @param methodName The name of the method on the class to hook into. * @param fn The hook to execute. * @param fallback A fallback function to be called in case the original super method does not exist. */ export declare function beforeMethod, Instance extends InstanceType, K extends PropertiesOfType, SuperMethod extends Instance[K]>(klass: Class, methodName: K, fn: (this: Instance, ...args: Parameters) => any, fallback?: (this: Instance, ...args: Parameters) => ReturnType): Class; /** * Executes the hook after the super method has been executed and passes the * return value to the hook. * * ```ts * class Foo { * bar(hello: string): boolean { * return true; * } * } * * afterMethod(Foo, 'bar', function(returnValue, hello) { * console.log('Do something here.'); * }); * ``` * * @param klass The class to hook into. * @param methodName The name of the method on the class to hook into. * @param fn The hook to execute. * @param fallback A fallback function to be called in case the original super method does not exist. */ export declare function afterMethod, Instance extends InstanceType, K extends PropertiesOfType, SuperMethod extends Instance[K]>(klass: Class, methodName: K, fn: (this: Instance, returnValue: ReturnType, ...args: Parameters) => any, fallback?: (this: Instance, ...args: Parameters) => ReturnType): Class;