`A.reject` loses type
declare const xs: Array<string>;
pipe(
xs,
A.reject((value) => {
value
// ^?
return true;
}),
);
The type of value is unknown but it should be string.
I can fix it with the following patch:
-export declare const reject: <A>(f: Predicate<A>) => <B extends A>(xs: B[]) => B[];
+export declare const reject: <A>(f: Predicate<A>) => (xs: A[]) => A[];
However I suspect this causes other issues (https://github.com/samhh/fp-ts-std/issues/122).
FWIW A.filter has these overloads:
export declare const filter: {
<A, B extends A>(refinement: Refinement<A, B>): (as: Array<A>) => Array<B>
<A>(predicate: Predicate<A>): <B extends A>(bs: Array<B>) => Array<B>
<A>(predicate: Predicate<A>): (as: Array<A>) => Array<A>
}
Without the first overload, inferrence fails. I don't understand why.
Without the second overload, that subtyping behaviour regresses.
We can possibly drop the third overload though, redundant in the presence of the second one.
I guess the same will need replicating to some other functions that support subtyping as per #122.
We can possibly drop the third overload though, redundant in the presence of the second one.
I think I found the same for O.fromPredicate: https://github.com/gcanti/fp-ts/issues/1808
I don't know how to solve this considering that reject can't support refinements. No other combination of overloads or playing with type arguments seems to work. :thinking: