immer
Version:
Create your next immutable state by mutating the current one
33 lines • 1.15 kB
TypeScript
import { ImmerBaseState, ImmerState, Drafted, ProxyType, AnyObject, AnyArray, Objectish } from "./internal";
interface ProxyBaseState extends ImmerBaseState {
assigned: {
[property: string]: boolean;
};
parent?: ImmerState;
drafts?: {
[property: string]: Drafted<any, any>;
};
revoke(): void;
}
export interface ProxyObjectState extends ProxyBaseState {
type: ProxyType.ProxyObject;
base: AnyObject;
copy: AnyObject | null;
draft: Drafted<AnyObject, ProxyObjectState>;
}
export interface ProxyArrayState extends ProxyBaseState {
type: ProxyType.ProxyArray;
base: AnyArray;
copy: AnyArray | null;
draft: Drafted<AnyArray, ProxyArrayState>;
}
declare type ProxyState = ProxyObjectState | ProxyArrayState;
/**
* Returns a new draft of the `base` object.
*
* The second argument is the parent draft-state (used internally).
*/
export declare function createProxy<T extends Objectish>(base: T, parent?: ImmerState): Drafted<T, ProxyState>;
export declare function markChanged(state: ImmerState): void;
export {};
//# sourceMappingURL=proxy.d.ts.map