import { Reducer } from 'redux'; import { PayloadAction } from './createAction'; import { CaseReducers } from './createReducer'; /** * An action creator atttached to a slice. */ export declare type SliceActionCreator

= P extends void ? () => PayloadAction : (payload: P) => PayloadAction

; export interface Slice { /** * The slice name. */ slice: string; /** * The slice's reducer. */ reducer: Reducer; /** * Action creators for the types of actions that are handled by the slice * reducer. */ actions: { [type in keyof AP]: SliceActionCreator; }; /** * Selectors for the slice reducer state. `createSlice()` inserts a single * selector that returns the entire slice state and whose name is * automatically derived from the slice name (e.g., `getCounter` for a slice * named `counter`). */ selectors: { [key: string]: (state: any) => S; }; } /** * Options for `createSlice()`. */ export interface CreateSliceOptions = CaseReducers> { /** * The slice's name. Used to namespace the generated action types and to * name the selector for retrieving the reducer's state. */ slice?: string; /** * The initial state to be returned by the slice reducer. */ initialState: S; /** * A mapping from action types to action-type-specific *case reducer* * functions. For every action type, a matching action creator will be * generated using `createAction()`. */ reducers: CR; /** * A mapping from action types to action-type-specific *case reducer* * functions. These reducers should have existing action types used * as the keys, and action creators will _not_ be generated. */ extraReducers?: CaseReducers; } declare type CaseReducerActionPayloads> = { [T in keyof CR]: CR[T] extends (state: any) => any ? void : (CR[T] extends (state: any, action: PayloadAction) => any ? P : void); }; /** * A function that accepts an initial state, an object full of reducer * functions, and optionally a "slice name", and automatically generates * action creators, action types, and selectors that correspond to the * reducers and state. * * The `reducer` argument is passed to `createReducer()`. */ export declare function createSlice>(options: CreateSliceOptions): Slice>; export {};