You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
775 B
TypeScript

import { Action, ActionCreatorsMapObject, AnyAction } from 'redux';
import { ThunkAction as _ThunkAction } from 'redux-thunk';
import { CombinedState } from '../reducers/interfaces';
export interface ActionWithPayload<T, P> extends Action<T> {
payload: P;
}
export function createAction<T extends string>(type: T): Action<T>;
export function createAction<T extends string, P>(type: T, payload: P): ActionWithPayload<T, P>;
export function createAction<T extends string, P>(type: T, payload?: P) {
return typeof payload === 'undefined' ? { type } : { type, payload };
}
export type ActionUnion<A extends ActionCreatorsMapObject> = ReturnType<A[keyof A]>;
export type ThunkAction<R = void, A extends Action = AnyAction>
= _ThunkAction<R, CombinedState, {}, A>;