TypeScript has the utility type Parameters that gives the parameter type of a function, like this:
function simple(a: number, b: string) {}
type SimpleParameters = Parameters<typeof simple>;
// is: [a: number, b: string]
How can I do the same for a generic function? This doesn't work:
function generic<T>(a: T, b: string) {}
type GenericParameters = Parameters<typeof generic>;
// expected: <T>[a: T, b: string]
// actual: [a: unknown, b: string]
And this won't even compile:
type GenericParameters<T> = Parameters<typeof generic<T>>;