WithFn<T>: { [ K in keyof T]: T[K] extends ((...args: infer P) => infer R) ? ((fn: ((...args: P) => R)) => void) : T[K] }

Utility type that adds a fn parameter to each method in the input type T, transforming the original method's parameter types and return type into a function type.

Example

// Input:
interface MyInterface {
method1(a: string, b: number): boolean;
method2(x: Foo, y: Bar): void;
}

// Output:
interface MyInterfaceWithFn {
method1(fn: (a: string, b: number) => boolean): void;
method2(fn: (x: Foo, y: Bar) => void): void;
}

Type Parameters

  • T

Generated using TypeDoc