Last active
September 19, 2019 11:37
-
-
Save kangax/f060f1c655431052501de036f30f513d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import type { GlobalState } from 'redux/modules'; | |
export type ExtractReturn<Fn> = $Call<<T>((...Iterable<any>) => T) => T, Fn>; | |
// ... | |
export type BaseAction = $ReadOnly<{ type: string, error?: boolean }>; | |
// ... | |
export type GetState<S> = () => S; | |
export type GetGlobalState = GetState<GlobalState>; | |
export type PromiseAction<A: BaseAction> = Promise<A>; | |
export type ThunkAction<A, S = GlobalState> = (dispatch: Dispatch<A>, getState: GetState<S>) => any; | |
export type Dispatch<A: BaseAction, S = GlobalState> = ( | |
action: A | ThunkAction<A, S> | PromiseAction<A> | Array<A> | |
) => Promise<*>; | |
// ... | |
export type DispatchLoose<A> = ( | |
action: A | ThunkAction<A> | PromiseAction<A> | Array<A> | |
) => Promise<any>; | |
// ... | |
export type ExtractReturnWithDispatch = <V>((...args: Array<*>) => V) => DispatchLoose<V>; | |
export type ReduxProps<M, D> = $ReadOnly<{| ...ExtractReturn<M>, ...ExtractReturn<D> |}>; | |
export type ReduxPropsWithDispatchShorthand<M, D> = $ReadOnly<{| | |
...ExtractReturn<M>, | |
...$ObjMap<D, ExtractReturnWithDispatch>, | |
|}>; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment