I'm at a loss as to how I can make this work. I'm defining a function in typescript that essentially wraps Ramda's pipe function. I want to accept values that may or may not be functions, wrap the non-function values in constant functions, and then pass it all to pipe.
Here's the original function I tried writing:
const convertToPipeable = (values: any[]) => {
const valueFunctions = map(valueAsFunction, values);
return pipe(...valueFunctions);
}
At the point where I spread valueFunctions over pipe, typescript complains saying "Expected 1-6 arguments, but got 0 or more". I realise it's because pipe is typed with overloads for each argument length case (from 1 until 6), but I'm having a hard time believing that it's not possible to spread this array over it. I've tried several things, from defining the values
argument as a big tuple, to using Ramda's apply
method in place of the spread operator, and none of these have worked properly.
If there is no good way to type this, what might be the alternative?
Cheers!