UNPKG

2.32 kBTypeScriptView Raw
1import type { AnyAction } from 'redux';
2import type { ThunkMiddleware } from 'redux-thunk';
3import type { ActionCreatorInvariantMiddlewareOptions } from './actionCreatorInvariantMiddleware';
4import type { ImmutableStateInvariantMiddlewareOptions } from './immutableStateInvariantMiddleware';
5import type { SerializableStateInvariantMiddlewareOptions } from './serializableStateInvariantMiddleware';
6import type { ExcludeFromTuple } from './tsHelpers';
7import { MiddlewareArray } from './utils';
8interface ThunkOptions<E = any> {
9 extraArgument: E;
10}
11interface GetDefaultMiddlewareOptions {
12 thunk?: boolean | ThunkOptions;
13 immutableCheck?: boolean | ImmutableStateInvariantMiddlewareOptions;
14 serializableCheck?: boolean | SerializableStateInvariantMiddlewareOptions;
15 actionCreatorCheck?: boolean | ActionCreatorInvariantMiddlewareOptions;
16}
17export declare type ThunkMiddlewareFor<S, O extends GetDefaultMiddlewareOptions = {}> = O extends {
18 thunk: false;
19} ? never : O extends {
20 thunk: {
21 extraArgument: infer E;
22 };
23} ? ThunkMiddleware<S, AnyAction, E> : ThunkMiddleware<S, AnyAction>;
24export declare type CurriedGetDefaultMiddleware<S = any> = <O extends Partial<GetDefaultMiddlewareOptions> = {
25 thunk: true;
26 immutableCheck: true;
27 serializableCheck: true;
28 actionCreatorCheck: true;
29}>(options?: O) => MiddlewareArray<ExcludeFromTuple<[ThunkMiddlewareFor<S, O>], never>>;
30export declare function curryGetDefaultMiddleware<S = any>(): CurriedGetDefaultMiddleware<S>;
31/**
32 * Returns any array containing the default middleware installed by
33 * `configureStore()`. Useful if you want to configure your store with a custom
34 * `middleware` array but still keep the default set.
35 *
36 * @return The default middleware used by `configureStore()`.
37 *
38 * @public
39 *
40 * @deprecated Prefer to use the callback notation for the `middleware` option in `configureStore`
41 * to access a pre-typed `getDefaultMiddleware` instead.
42 */
43export declare function getDefaultMiddleware<S = any, O extends Partial<GetDefaultMiddlewareOptions> = {
44 thunk: true;
45 immutableCheck: true;
46 serializableCheck: true;
47 actionCreatorCheck: true;
48}>(options?: O): MiddlewareArray<ExcludeFromTuple<[ThunkMiddlewareFor<S, O>], never>>;
49export {};