The following example gives a compile error:
import { anyPass, filter } from "rambda";
const isGt5 = (num: number) => num > 5;
const pred = anyPass([isGt5]);
const xs = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
const filtered1 = filter(pred)(xs); // works
const filtered2 = xs.filter(pred); // compile error
This is the compile error:
No overload matches this call.
Overload 1 of 2, '(predicate: (value: number, index: number, array: number[]) => value is number, thisArg?: any): number[]', gave the following error.
Argument of type 'SafePred<number>' is not assignable to parameter of type '(value: number, index: number, array: number[]) => value is number'.
You can see this example in action here: https://codesandbox.io/s/pedantic-jennings-ret7c2?file=/src/index.ts
I think this is because of the type definition of SafePred, which is incompatible with the definition of the function taken in by array .filter. I'm not sure why SafePred is defined this way, with (...x: T[]) as the arguments. Shouldn't it be just (x: T)?
The following example gives a compile error:
This is the compile error:
You can see this example in action here: https://codesandbox.io/s/pedantic-jennings-ret7c2?file=/src/index.ts
I think this is because of the type definition of
SafePred, which is incompatible with the definition of the function taken in by array.filter. I'm not sure whySafePredis defined this way, with(...x: T[])as the arguments. Shouldn't it be just(x: T)?