I would like to be able to take a function with n number of arguments and return a type based on that function where any argument with type x is no longer in the function type. For example:
function myTestFunction(email: string, context: TestContext, password: string): void {
...
}
I would like a type to use on that to create a function definition like this:
function myTestFunction(email: string, password: string): void {
...
}
I've managed to do it with this:
type Filter<T> = T extends []
? []
: T extends [infer A, ...infer B]
? A extends TestContext
? Filter<B>
: [A, ...Filter<B>]
: T;
type ConvertFunction<T> = T extends (...args: any[]) => any
? (...args: Filter<Parameters<T>>) => ReturnType<T>
: T;
The only problem is that the parameter names are lost and the signature becomes:
function myTestFunction(args_0: string, args_1: string): void {
...
}
How would it be possible to do this without losing the parameter names please?