import { Draft } from 'immer'; import { StateCreator } from 'zustand'; /** * Slice setter with automatic action naming * Wraps the standard set function to add DevTools action names */ export type SliceSetter = { /** * Update state with an updater function (Immer-style) * @param updater - Function that mutates draft state * @param actionName - Optional action name for DevTools */ (updater: (state: Draft) => void, actionName?: string): void; /** * Update state with partial state * @param partial - Partial state to merge * @param actionName - Optional action name for DevTools */ (partial: Partial, actionName?: string): void; }; /** * Slice getter that returns only slice state */ export type SliceGetter = () => TState; /** * Slice configuration */ export interface SliceConfig { /** Slice name (used in DevTools action prefixes) */ name: string; /** Initial state */ initialState: TState; /** Action creators */ actions: (set: SliceSetter, get: SliceGetter) => TActions; } /** * Create a type-safe slice with automatic action naming * * Features: * - Automatic action naming for DevTools (format: "sliceName/actionName") * - Immer-compatible state updates * - Slice-scoped getter that only returns slice state * - Full TypeScript inference * * @example * ```typescript * export const counterSlice = createSlice({ * name: 'counter', * initialState: { count: 0 }, * actions: (set, get) => ({ * increment: () => { * set((state) => { state.count += 1 }, 'increment'); * }, * decrement: () => { * set((state) => { state.count -= 1 }, 'decrement'); * }, * incrementBy: (amount: number) => { * set((state) => { state.count += amount }, 'incrementBy'); * }, * getCount: () => get().count, * }), * }); * ``` */ export declare function createSlice unknown>, TStore extends TState & TActions = TState & TActions>(config: SliceConfig): StateCreator; /** * Extract state type from a slice config */ export type SliceState = T extends SliceConfig ? S : never; /** * Extract actions type from a slice config */ export type SliceActions = T extends SliceConfig ? A : never; /** * Extract full slice type (state + actions) from a slice config */ export type SliceType = T extends SliceConfig ? S & A : never; /** * Create a simple action creator (for use outside createSlice) * * @example * ```typescript * const increment = createAction('counter/increment', (set) => (amount) => { * set((state) => { state.count += amount }); * }); * ``` */ export declare function createAction(_type: string, handler: (set: (updater: (state: Draft) => void) => void) => TPayload extends void ? () => void : (payload: TPayload) => void): TPayload extends void ? () => void : (payload: TPayload) => void; /** * Combine multiple slices into a single state creator * * @example * ```typescript * const useStore = create( * combineSlices(counterSlice, uiSlice, settingsSlice) * ); * ``` */ export declare function combineSlices(...slices: StateCreator[]): StateCreator;