123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- export interface Patch {
- op: "replace" | "remove" | "add";
- path: (string | number)[];
- value?: any;
- }
- export type PatchListener = (patches: Patch[], inversePatches: Patch[]) => void
- type Base = {...} | Array<any>
- interface IProduce {
-
- <S: Base>(
- currentState: S,
- recipe: (draftState: S) => S | void,
- patchListener?: PatchListener
- ): S;
-
- <S: Base, A = void, B = void, C = void>(
- recipe: (draftState: S, a: A, b: B, c: C, ...extraArgs: any[]) => S | void,
- initialState: S
- ): (currentState: S | void, a: A, b: B, c: C, ...extraArgs: any[]) => S;
-
- <S: Base, A = void, B = void, C = void>(
- recipe: (draftState: S, a: A, b: B, c: C, ...extraArgs: any[]) => S | void
- ): (currentState: S, a: A, b: B, c: C, ...extraArgs: any[]) => S;
- }
- interface IProduceWithPatches {
-
- <S: Base>(
- currentState: S,
- recipe: (draftState: S) => S | void
- ): [S, Patch[], Patch[]];
-
- <S: Base, A = void, B = void, C = void>(
- recipe: (draftState: S, a: A, b: B, c: C, ...extraArgs: any[]) => S | void,
- initialState: S
- ): (currentState: S | void, a: A, b: B, c: C, ...extraArgs: any[]) => [S, Patch[], Patch[]];
-
- <S: Base, A = void, B = void, C = void>(
- recipe: (draftState: S, a: A, b: B, c: C, ...extraArgs: any[]) => S | void
- ): (currentState: S, a: A, b: B, c: C, ...extraArgs: any[]) => [S, Patch[], Patch[]];
- }
- declare export var produce: IProduce
- declare export default IProduce
- declare export var produceWithPatches: IProduceWithPatches
- declare export var nothing: typeof undefined
- declare export var immerable: Symbol
- declare export function setAutoFreeze(autoFreeze: boolean): void
- declare export function setUseProxies(useProxies: boolean): void
- declare export function applyPatches<S>(state: S, patches: Patch[]): S
- declare export function original<S>(value: S): S
- declare export function current<S>(value: S): S
- declare export function isDraft(value: any): boolean
- declare export function createDraft<T>(base: T): T
- declare export function finishDraft<T>(base: T, listener?: PatchListener): T
- declare export function enableES5(): void
- declare export function enableMapSet(): void
- declare export function enablePatches(): void
- declare export function enableAllPlugins(): void
- declare export function freeze<T>(obj: T, freeze?: boolean): T
|