// Type definitions for redux-actions 2.6 // Project: https://github.com/redux-utilities/redux-actions // Definitions by: Jack Hsu , // Alex Gorbatchev , // Alec Hill // Alexey Pelykh // Thiago de Andrade // Ziyu // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 export as namespace ReduxActions; // FSA-compliant action. // See: https://github.com/acdlite/flux-standard-action export interface BaseAction { type: string; } export interface Action extends BaseAction { payload: Payload; error?: boolean | undefined; } export interface ActionMeta extends Action { meta: Meta; } // https://github.com/redux-utilities/redux-actions/blob/v2.3.0/src/combineActions.js#L27 export interface CombinedActionType { _dummy: undefined; } export type ReducerMapValue = Reducer | ReducerNextThrow | ReducerMap; export interface ReducerMap { [actionType: string]: ReducerMapValue; } export interface ReducerMapMeta { [actionType: string]: ReducerMeta | ReducerNextThrowMeta | ReducerMapMeta; } export interface ReducerNextThrow { next?(state: State, action: Action): State; throw?(state: State, action: Action): State; } export interface ReducerNextThrowMeta { next?(state: State, action: ActionMeta): State; throw?(state: State, action: ActionMeta): State; } export type BaseActionFunctions = ActionFunction0 | ActionFunction1 | ActionFunction2 | ActionFunction3 | ActionFunction4 | ActionFunctionAny; export type ActionFunctions = BaseActionFunctions>; export type ActionWithMetaFunctions = BaseActionFunctions>; export type Reducer = (state: State, action: Action) => State; export type ReducerMeta = (state: State, action: ActionMeta) => State; export type ReduxCompatibleReducer = (state: State | undefined, action: Action) => State; export type ReduxCompatibleReducerMeta = (state: State | undefined, action: ActionMeta) => State; /** argument inferring borrowed from lodash definitions */ export type ActionFunction0 = () => R; export type ActionFunction1 = (t1: T1) => R; export type ActionFunction2 = (t1: T1, t2: T2) => R; export type ActionFunction3 = (t1: T1, t2: T2, t3: T3) => R; export type ActionFunction4 = (t1: T1, t2: T2, t3: T3, t4: T4) => R; export type ActionFunctionAny = (...args: any[]) => R; // https://github.com/redux-utilities/redux-actions/blob/v2.3.0/src/createAction.js#L6 export function createAction( actionType: string ): ActionFunctionAny>; export function createAction( actionType: string, payloadCreator: ActionFunction0 ): ActionFunction0>; export function createAction( actionType: string, payloadCreator: ActionFunction1 ): ActionFunction1>; export function createAction( actionType: string, payloadCreator: ActionFunction2 ): ActionFunction2>; export function createAction( actionType: string, payloadCreator: ActionFunction3 ): ActionFunction3>; export function createAction( actionType: string, payloadCreator: ActionFunction4 ): ActionFunction4>; export function createAction( actionType: string ): ActionFunction1>; export function createAction( actionType: string, payloadCreator: null | undefined, metaCreator: ActionFunctionAny ): ActionFunctionAny>; export function createAction( actionType: string, payloadCreator: ActionFunctionAny, metaCreator: ActionFunctionAny ): ActionFunctionAny>; export function createAction( actionType: string, payloadCreator: ActionFunction1, metaCreator: ActionFunction1 ): ActionFunction1>; export function createAction( actionType: string, payloadCreator: ActionFunction2, metaCreator: ActionFunction2 ): ActionFunction2>; export function createAction( actionType: string, payloadCreator: ActionFunction3, metaCreator: ActionFunction3 ): ActionFunction3>; export function createAction( actionType: string, payloadCreator: ActionFunction4, metaCreator: ActionFunction4 ): ActionFunction4>; export function handleAction( actionType: string | ActionFunctions | CombinedActionType, reducer: Reducer | ReducerNextThrow, initialState: State ): ReduxCompatibleReducer; export function handleAction( actionType: string | ActionWithMetaFunctions | CombinedActionType, reducer: ReducerMeta | ReducerNextThrowMeta, initialState: State ): ReduxCompatibleReducerMeta; export interface Options { prefix?: string | undefined; namespace?: string | undefined; } export function handleActions( reducerMap: ReducerMap, initialState: StateAndPayload, options?: Options ): ReduxCompatibleReducer; export function handleActions( reducerMap: ReducerMap, initialState: State, options?: Options ): ReduxCompatibleReducer; export function handleActions( reducerMap: ReducerMapMeta, initialState: State, options?: Options ): ReduxCompatibleReducerMeta; // https://github.com/redux-utilities/redux-actions/blob/v2.3.0/src/combineActions.js#L21 export function combineActions(...actionTypes: Array | string | symbol>): CombinedActionType; export interface ActionMap { [actionType: string]: ActionMap | ActionFunctionAny | [ActionFunctionAny, ActionFunctionAny] | undefined; } export function createActions( actionMapOrIdentityAction: ActionMap | string, ...identityActions: Array ): { [actionName: string]: ActionFunctionAny> }; export function createActions( actionMapOrIdentityAction: ActionMap | string, ...identityActions: Array ): { [actionName: string]: ActionFunctionAny> };