import { Draft } from 'immer'; import { ActionCreatorWithoutPayload, PayloadAction, PayloadActionCreator, Thunk, ThunkFunction } from '../../types'; import { ActionsUnionType, IsUnknownOrNonInferrable, NoInfer } from '../tsHelpers'; import { ComponentPropsType } from '../../connect/types'; export type ActionTypeName = ActionName extends string | number ? `${SliceName}/${ActionName}` : string; type SliceReducer = (state: Draft, payload?: P) => NoInfer | void | Draft>; export type CreateSliceActions = { [K: string]: SliceReducer; }; export interface CreateSliceProps, MT extends ThunkActions>, N extends string, S extends ComponentPropsType, A extends CreateSliceActions> { name: N; initialState: S; actions?: A; extends?: { module: { actions: MA; getThunks?: (actions: ReducerActionCreators) => MT; initialState: MS; }; }; } type ActionCreatorForReducer = ActionFunction extends (state: any, payload: infer Payload) => any ? IsUnknownOrNonInferrable, PayloadActionCreator> : ActionCreatorWithoutPayload; export type ReducerActionCreators, SliceName extends string> = { [Type in keyof Actions]: ActionCreatorForReducer>; }; export type SliceReducers = { [K: string]: SliceReducer; }; export interface ThunkActions> { [key: string]: ThunkFunction | Thunk>; } export interface ThunkActionsHelper { [key: string]: ThunkFunction>; } export {};