Skip to content

Commit

Permalink
fix: more explicit typing to avoid TS4025
Browse files Browse the repository at this point in the history
It's ugly though. We'll try to find another way to type this
  • Loading branch information
Jazzmanpw authored and the-dr-lazy committed Oct 1, 2020
1 parent 611184d commit e703730
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/create-handler-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,27 @@ handle.default = <
* @example
* createHandlerMap.default((state: number) => state + 1)
*/
export const createHandlerMap = handle as typeof handle & { default: typeof handle.default }
export const createHandlerMap = handle as (<
TActionCreator extends ActionCreator<any>,
TPrevState,
TNextState extends TPrevState,
TAction extends AnyAction = TActionCreator extends (...args: any[]) => infer T
? T
: never
>(
actionCreators: TActionCreator | TActionCreator[],
handler: Handler<TPrevState, TAction, TNextState>
) => HandlerMap<TPrevState, TAction, TNextState>) & {
default: <
TActionCreator extends ActionCreator<any>,
TPrevState,
TNextState extends TPrevState,
TAction extends AnyAction = TActionCreator extends (...args: any[]) => infer T
? T
: never
>(
handler: Handler<TPrevState, TAction, TNextState>
) => { default: Handler<TPrevState, TAction, TNextState> }
}


0 comments on commit e703730

Please sign in to comment.