Effect type inference error on typescript 4.9
Type inference for effects fails when payload and rootState are optional. It can be observed in here: https://github.com/rematch/rematch/blob/bde199f08c7709e81458394d2bb9374ad95600a2/packages/core/test/ts_typings/dispatcher-typings.test.ts#L338-L339
Reproduce Link
https://codesandbox.io/s/rematch-ts-4-9-error-w4sz3r
To Reproduce
Use typescript 4.9+
Expected behavior
I should correctly infer the effect type.
Additional context
Not sure if this is a rematch or typescript bug. I was debugged the types in rematch and tracked it down to type ExtractRematchDispatcherFromEffect on this line https://github.com/rematch/rematch/blob/bde199f08c7709e81458394d2bb9374ad95600a2/packages/core/src/types.ts#L576
The effect function with optional args is not matching (...args: infer TRest) so it infers to never.
Source: rematch/rematch