import type { ThunkAction, ThunkDispatch } from 'redux-thunk'; import type { ActionCreatorFactory, AnyAction, AsyncActionCreators, Meta } from 'typescript-fsa'; /** * This interface can be augmented by users to add default types for the root state when * using `typescript-fsa-redux-thunk`. * Use module augmentation to append your own type definition in a your_custom_type.d.ts file. * https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation */ export interface DefaultRootState { } /** * It's either a promise, or it isn't */ export declare type MaybePromise = T | Promise; /** * A redux-thunk with the params as the first argument. You don't have to * return a promise; but, the result of the dispatch will be one. */ export declare type AsyncWorker = (params: InputType, dispatch: ThunkDispatch, getState: () => State, extraArgument: Extra) => MaybePromise; /** Workaround for typescript-fsa issue #77 */ export declare type ThunkReturnType = T extends void ? unknown : T extends Promise ? Promise : T; declare type SmartThunkFunction = unknown extends InputType ? ThunkFunctionWithoutParams, State, Error, Extra> : ThunkFunction, State, Error, Extra>; /** * Factory function to easily create a thunk * @param factory typescript-fsa action creator factory * @returns an function that takes * - the `type` of the action, * - the your worker thunk function * And returns object with the async actions and the thunk itself */ export declare const asyncFactory: (factory: ActionCreatorFactory, resolve?: () => Promise) => (type: string, worker: AsyncWorker, State, Extra>, commonMeta?: Meta | undefined) => SmartThunkFunction; export declare type ThunkFunctionAction = (dispatch: ThunkDispatch, getState: () => State, extraArgument: Extra) => Promise; export interface ThunkFunction { (params: InputType): ThunkFunctionAction; action(params: InputType): ThunkFunctionAction; async: AsyncActionCreators; } export interface ThunkFunctionWithoutParams { (): ThunkFunctionAction; action(): ThunkFunctionAction; async: AsyncActionCreators; } /** Utility type for a function that takes paras and returns a redux-thunk */ export declare type ThunkCreator = (params?: InputType) => ThunkAction, State, unknown, AnyAction>; /** The result type for thunkToAction below */ export declare type ThunkFn = (params?: InputType) => Promise; /** * Passing the result of this to bindActionCreators and then calling the result * is equivalent to calling `store.dispatch(thunkCreator(params))`. Useful * for when you pass it to `connect()` in an action creators map object. * @param thunkCreator The thunk action creator * @returns thunkAction as if it was bound */ export declare function thunkToAction(thunkCreator: ThunkCreator): ThunkFn; export default asyncFactory; //# sourceMappingURL=index.d.ts.map