UNPKG

1.68 kBTypeScriptView Raw
1import type { Middleware } from 'redux';
2/**
3 * The default `isImmutable` function.
4 *
5 * @public
6 */
7export declare function isImmutableDefault(value: unknown): boolean;
8export declare function trackForMutations(isImmutable: IsImmutableFunc, ignorePaths: string[] | undefined, obj: any): {
9 detectMutations(): {
10 wasMutated: boolean;
11 path?: string | undefined;
12 };
13};
14declare type IsImmutableFunc = (value: any) => boolean;
15/**
16 * Options for `createImmutableStateInvariantMiddleware()`.
17 *
18 * @public
19 */
20export interface ImmutableStateInvariantMiddlewareOptions {
21 /**
22 Callback function to check if a value is considered to be immutable.
23 This function is applied recursively to every value contained in the state.
24 The default implementation will return true for primitive types
25 (like numbers, strings, booleans, null and undefined).
26 */
27 isImmutable?: IsImmutableFunc;
28 /**
29 An array of dot-separated path strings that match named nodes from
30 the root state to ignore when checking for immutability.
31 Defaults to undefined
32 */
33 ignoredPaths?: string[];
34 /** Print a warning if checks take longer than N ms. Default: 32ms */
35 warnAfter?: number;
36 ignore?: string[];
37}
38/**
39 * Creates a middleware that checks whether any state was mutated in between
40 * dispatches or during a dispatch. If any mutations are detected, an error is
41 * thrown.
42 *
43 * @param options Middleware options.
44 *
45 * @public
46 */
47export declare function createImmutableStateInvariantMiddleware(options?: ImmutableStateInvariantMiddlewareOptions): Middleware;
48export {};