I am delving into the world of typed functional programming and have embarked on implementing partial application with a focus on type safety.
Issue at hand: I'm aiming to create a function that can take a function along with zero or all of its parameters as arguments.
Here is the initial interface:
interface Functor {
(...args: any[]) => any
}
This led me to develop the following function:
const partial = <T extends Functor>(fx: T, ...apply: Parameters<T>): Functor =>
(...args: any[]) => fx(...apply, ...args);
The dilemma lies in ...args: Parameter<T>
, which prompts typescript to expect all parameters whereas I want to allow zero up to all.
Is there a workaround for this particular issue?