UNPKG

redux-dry-ts-actions

Version:

Micro library to create actions for redux with automatically inferred TypeScript types

20 lines (19 loc) 772 B
export declare type ActionCreator<T extends string> = { actionType: T; (): { type: T; }; }; export declare type ActionCreatorWithPayload<T extends string, Payload, Args extends Array<any>> = { actionType: T; (...args: Args): { type: T; payload: Payload; }; }; export declare type KeysToFunctions = { [key: string]: (...args: Array<any>) => any; }; export declare type ActionTypeFromActionCreators<T extends KeysToFunctions> = ReturnType<T[keyof T]>; export declare function createAction<T extends string>(type: T): ActionCreator<T>; export declare function createAction<T extends string, Payload, Args extends Array<any>>(type: T, payloadCreator: (...args: Args) => Payload): ActionCreatorWithPayload<T, Payload, Args>;