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.

28 lines
1.0 KiB
TypeScript

// Copyright (C) 2020 Intel Corporation
//
// SPDX-License-Identifier: MIT
import { Action, ActionCreatorsMapObject, AnyAction } from 'redux';
import { ThunkAction as _ThunkAction, ThunkDispatch as _ThunkDispatch } 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,
): Action<T> | ActionWithPayload<T, 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>;
export type ThunkDispatch<E = void, A extends Action = AnyAction>
= _ThunkDispatch<CombinedState, E, A>;