// eslint-disable-next-line import/named import {Draft} from 'immer' export interface ReimOptions { name?: string; actions?: Actions; } export type Mutation = ((state: Draft | TS) => void | TS) | Partial | TS export type Action = ((...args: any[]) => Mutation) export type Actions = {[index: string]: Action} // export type Effect = (...args: any[]) => (store: TR) => any // export type Effects = {[index: string]: Effect} export type Cache = TF extends ((s: TS) => any) ? ReturnType : TF extends {[index: string]: (s: TS) => TS} ? {[Tk in keyof TF]: ReturnType} : any export type Filter = | ((s: TS) => any) | {[index: string]: ((s: TS) => any)} | keyof TS export type SnapshotFor = TF extends ((s: any) => any) // TF extends (null | undefined) ? T : ? ReturnType : TF extends { [index: string]: ((s: T) => any); } ? {[Tk in keyof TF]: ReturnType} : TF extends keyof T ? T[TF] : T export type Meta = { mutation?: string; payload?: any[]; } export type Handler = | {next: (s: T, meta?: Meta) => any} | ((s: T, meta?: Meta) => any)