Typescript type guard for Function with Parameters


Kinda hard to explain.

type FunctionWithArguments<T> = (...args: T[]) => T;

Some in-built implementations:

type Parameters<O extends (...args: any[]) => any> = O extends ( ...args: infer P ) => any ? P : never; type ReturnType<O extends (...args: any[]) => any> = O extends ( ...args: any[] ) => infer P ? P : never;