The projector argument (last argument) of createSelector is a pure function that uses the resultant values of the other selectors passed to define the result of a the new selector. It is available as the MemoizedSelector's project member, and this should be ideal for unit-testing selectors.
However, in all current signatures of createSelector, the ProjectorFn type argument of the return type MemoizedSelector is unspecified, meaning it defaults to DefaultProjectorFn<Result>, or (...args: any[]) => Result. It's nice that the Result type is available, but without the argument types, the unit tests become a little harder to write (at least for those of us who like to use Typescript to help guide their unit tests).
Luckily, this issue can be easily solved by simply providing the full projector type in createSelector's return type, e.g.
Before:
declare function createSelector<State, S1, S2, Result>(
s1: Selector<State, S1>,
s2: Selector<State, S2>,
projector: (s1: S1, s2: S2) => Result
): MemoizedSelector<State, Result>;
After:
declare function createSelector<State, S1, S2, Result>(
s1: Selector<State, S1>,
s2: Selector<State, S2>,
projector: (s1: S1, s2: S2) => Result
): MemoizedSelector<State, Result, (s1: S1, s2: S2) => Result>;
Please see this Typescript playground link for a worker example of the additional type safety that this change would provide.
If accepted, I would be willing to submit a PR for this feature
[x] Yes (Preferably after #3023 is merged)
[ ] No