UNPKG

28.5 kBTypeScriptView Raw
1/**
2 * An *action* is a plain object that represents an intention to change the
3 * state. Actions are the only way to get data into the store. Any data,
4 * whether from UI events, network callbacks, or other sources such as
5 * WebSockets needs to eventually be dispatched as actions.
6 *
7 * Actions must have a `type` field that indicates the type of action being
8 * performed. Types can be defined as constants and imported from another
9 * module. These must be strings, as strings are serializable.
10 *
11 * Other than `type`, the structure of an action object is really up to you.
12 * If you're interested, check out Flux Standard Action for recommendations on
13 * how actions should be constructed.
14 *
15 * @template T the type of the action's `type` tag.
16 */
17type Action<T extends string = string> = {
18 type: T;
19};
20/**
21 * An Action type which accepts any other properties.
22 * This is mainly for the use of the `Reducer` type.
23 * This is not part of `Action` itself to prevent types that extend `Action` from
24 * having an index signature.
25 */
26interface UnknownAction extends Action {
27 [extraProps: string]: unknown;
28}
29/**
30 * An Action type which accepts any other properties.
31 * This is mainly for the use of the `Reducer` type.
32 * This is not part of `Action` itself to prevent types that extend `Action` from
33 * having an index signature.
34 * @deprecated use Action or UnknownAction instead
35 */
36interface AnyAction extends Action {
37 [extraProps: string]: any;
38}
39/**
40 * An *action creator* is, quite simply, a function that creates an action. Do
41 * not confuse the two terms—again, an action is a payload of information, and
42 * an action creator is a factory that creates an action.
43 *
44 * Calling an action creator only produces an action, but does not dispatch
45 * it. You need to call the store's `dispatch` function to actually cause the
46 * mutation. Sometimes we say *bound action creators* to mean functions that
47 * call an action creator and immediately dispatch its result to a specific
48 * store instance.
49 *
50 * If an action creator needs to read the current state, perform an API call,
51 * or cause a side effect, like a routing transition, it should return an
52 * async action instead of an action.
53 *
54 * @template A Returned action type.
55 */
56interface ActionCreator<A, P extends any[] = any[]> {
57 (...args: P): A;
58}
59/**
60 * Object whose values are action creator functions.
61 */
62interface ActionCreatorsMapObject<A = any, P extends any[] = any[]> {
63 [key: string]: ActionCreator<A, P>;
64}
65
66/**
67 * A *reducer* is a function that accepts
68 * an accumulation and a value and returns a new accumulation. They are used
69 * to reduce a collection of values down to a single value
70 *
71 * Reducers are not unique to Redux—they are a fundamental concept in
72 * functional programming. Even most non-functional languages, like
73 * JavaScript, have a built-in API for reducing. In JavaScript, it's
74 * `Array.prototype.reduce()`.
75 *
76 * In Redux, the accumulated value is the state object, and the values being
77 * accumulated are actions. Reducers calculate a new state given the previous
78 * state and an action. They must be *pure functions*—functions that return
79 * the exact same output for given inputs. They should also be free of
80 * side-effects. This is what enables exciting features like hot reloading and
81 * time travel.
82 *
83 * Reducers are the most important concept in Redux.
84 *
85 * *Do not put API calls into reducers.*
86 *
87 * @template S The type of state consumed and produced by this reducer.
88 * @template A The type of actions the reducer can potentially respond to.
89 * @template PreloadedState The type of state consumed by this reducer the first time it's called.
90 */
91type Reducer<S = any, A extends Action = UnknownAction, PreloadedState = S> = (state: S | PreloadedState | undefined, action: A) => S;
92/**
93 * Object whose values correspond to different reducer functions.
94 *
95 * @template S The combined state of the reducers.
96 * @template A The type of actions the reducers can potentially respond to.
97 * @template PreloadedState The combined preloaded state of the reducers.
98 */
99type ReducersMapObject<S = any, A extends Action = UnknownAction, PreloadedState = S> = keyof PreloadedState extends keyof S ? {
100 [K in keyof S]: Reducer<S[K], A, K extends keyof PreloadedState ? PreloadedState[K] : never>;
101} : never;
102/**
103 * Infer a combined state shape from a `ReducersMapObject`.
104 *
105 * @template M Object map of reducers as provided to `combineReducers(map: M)`.
106 */
107type StateFromReducersMapObject<M> = M[keyof M] extends Reducer<any, any, any> | undefined ? {
108 [P in keyof M]: M[P] extends Reducer<infer S, any, any> ? S : never;
109} : never;
110/**
111 * Infer reducer union type from a `ReducersMapObject`.
112 *
113 * @template M Object map of reducers as provided to `combineReducers(map: M)`.
114 */
115type ReducerFromReducersMapObject<M> = M[keyof M] extends Reducer<any, any, any> | undefined ? M[keyof M] : never;
116/**
117 * Infer action type from a reducer function.
118 *
119 * @template R Type of reducer.
120 */
121type ActionFromReducer<R> = R extends Reducer<any, infer A, any> ? A : never;
122/**
123 * Infer action union type from a `ReducersMapObject`.
124 *
125 * @template M Object map of reducers as provided to `combineReducers(map: M)`.
126 */
127type ActionFromReducersMapObject<M> = ActionFromReducer<ReducerFromReducersMapObject<M>>;
128/**
129 * Infer a combined preloaded state shape from a `ReducersMapObject`.
130 *
131 * @template M Object map of reducers as provided to `combineReducers(map: M)`.
132 */
133type PreloadedStateShapeFromReducersMapObject<M> = M[keyof M] extends Reducer<any, any, any> | undefined ? {
134 [P in keyof M]: M[P] extends (inputState: infer InputState, action: UnknownAction) => any ? InputState : never;
135} : never;
136
137/**
138 * A *dispatching function* (or simply *dispatch function*) is a function that
139 * accepts an action or an async action; it then may or may not dispatch one
140 * or more actions to the store.
141 *
142 * We must distinguish between dispatching functions in general and the base
143 * `dispatch` function provided by the store instance without any middleware.
144 *
145 * The base dispatch function *always* synchronously sends an action to the
146 * store's reducer, along with the previous state returned by the store, to
147 * calculate a new state. It expects actions to be plain objects ready to be
148 * consumed by the reducer.
149 *
150 * Middleware wraps the base dispatch function. It allows the dispatch
151 * function to handle async actions in addition to actions. Middleware may
152 * transform, delay, ignore, or otherwise interpret actions or async actions
153 * before passing them to the next middleware.
154 *
155 * @template A The type of things (actions or otherwise) which may be
156 * dispatched.
157 */
158interface Dispatch<A extends Action = UnknownAction> {
159 <T extends A>(action: T, ...extraArgs: any[]): T;
160}
161/**
162 * Function to remove listener added by `Store.subscribe()`.
163 */
164interface Unsubscribe {
165 (): void;
166}
167type ListenerCallback = () => void;
168declare global {
169 interface SymbolConstructor {
170 readonly observable: symbol;
171 }
172}
173/**
174 * A minimal observable of state changes.
175 * For more information, see the observable proposal:
176 * https://github.com/tc39/proposal-observable
177 */
178type Observable<T> = {
179 /**
180 * The minimal observable subscription method.
181 * @param {Object} observer Any object that can be used as an observer.
182 * The observer object should have a `next` method.
183 * @returns {subscription} An object with an `unsubscribe` method that can
184 * be used to unsubscribe the observable from the store, and prevent further
185 * emission of values from the observable.
186 */
187 subscribe: (observer: Observer<T>) => {
188 unsubscribe: Unsubscribe;
189 };
190 [Symbol.observable](): Observable<T>;
191};
192/**
193 * An Observer is used to receive data from an Observable, and is supplied as
194 * an argument to subscribe.
195 */
196type Observer<T> = {
197 next?(value: T): void;
198};
199/**
200 * A store is an object that holds the application's state tree.
201 * There should only be a single store in a Redux app, as the composition
202 * happens on the reducer level.
203 *
204 * @template S The type of state held by this store.
205 * @template A the type of actions which may be dispatched by this store.
206 * @template StateExt any extension to state from store enhancers
207 */
208interface Store<S = any, A extends Action = UnknownAction, StateExt extends unknown = unknown> {
209 /**
210 * Dispatches an action. It is the only way to trigger a state change.
211 *
212 * The `reducer` function, used to create the store, will be called with the
213 * current state tree and the given `action`. Its return value will be
214 * considered the **next** state of the tree, and the change listeners will
215 * be notified.
216 *
217 * The base implementation only supports plain object actions. If you want
218 * to dispatch a Promise, an Observable, a thunk, or something else, you
219 * need to wrap your store creating function into the corresponding
220 * middleware. For example, see the documentation for the `redux-thunk`
221 * package. Even the middleware will eventually dispatch plain object
222 * actions using this method.
223 *
224 * @param action A plain object representing “what changed”. It is a good
225 * idea to keep actions serializable so you can record and replay user
226 * sessions, or use the time travelling `redux-devtools`. An action must
227 * have a `type` property which may not be `undefined`. It is a good idea
228 * to use string constants for action types.
229 *
230 * @returns For convenience, the same action object you dispatched.
231 *
232 * Note that, if you use a custom middleware, it may wrap `dispatch()` to
233 * return something else (for example, a Promise you can await).
234 */
235 dispatch: Dispatch<A>;
236 /**
237 * Reads the state tree managed by the store.
238 *
239 * @returns The current state tree of your application.
240 */
241 getState(): S & StateExt;
242 /**
243 * Adds a change listener. It will be called any time an action is
244 * dispatched, and some part of the state tree may potentially have changed.
245 * You may then call `getState()` to read the current state tree inside the
246 * callback.
247 *
248 * You may call `dispatch()` from a change listener, with the following
249 * caveats:
250 *
251 * 1. The subscriptions are snapshotted just before every `dispatch()` call.
252 * If you subscribe or unsubscribe while the listeners are being invoked,
253 * this will not have any effect on the `dispatch()` that is currently in
254 * progress. However, the next `dispatch()` call, whether nested or not,
255 * will use a more recent snapshot of the subscription list.
256 *
257 * 2. The listener should not expect to see all states changes, as the state
258 * might have been updated multiple times during a nested `dispatch()` before
259 * the listener is called. It is, however, guaranteed that all subscribers
260 * registered before the `dispatch()` started will be called with the latest
261 * state by the time it exits.
262 *
263 * @param listener A callback to be invoked on every dispatch.
264 * @returns A function to remove this change listener.
265 */
266 subscribe(listener: ListenerCallback): Unsubscribe;
267 /**
268 * Replaces the reducer currently used by the store to calculate the state.
269 *
270 * You might need this if your app implements code splitting and you want to
271 * load some of the reducers dynamically. You might also need this if you
272 * implement a hot reloading mechanism for Redux.
273 *
274 * @param nextReducer The reducer for the store to use instead.
275 */
276 replaceReducer(nextReducer: Reducer<S, A>): void;
277 /**
278 * Interoperability point for observable/reactive libraries.
279 * @returns {observable} A minimal observable of state changes.
280 * For more information, see the observable proposal:
281 * https://github.com/tc39/proposal-observable
282 */
283 [Symbol.observable](): Observable<S & StateExt>;
284}
285type UnknownIfNonSpecific<T> = {} extends T ? unknown : T;
286/**
287 * A store creator is a function that creates a Redux store. Like with
288 * dispatching function, we must distinguish the base store creator,
289 * `createStore(reducer, preloadedState)` exported from the Redux package, from
290 * store creators that are returned from the store enhancers.
291 *
292 * @template S The type of state to be held by the store.
293 * @template A The type of actions which may be dispatched.
294 * @template PreloadedState The initial state that is passed into the reducer.
295 * @template Ext Store extension that is mixed in to the Store type.
296 * @template StateExt State extension that is mixed into the state type.
297 */
298interface StoreCreator {
299 <S, A extends Action, Ext extends {} = {}, StateExt extends {} = {}>(reducer: Reducer<S, A>, enhancer?: StoreEnhancer<Ext, StateExt>): Store<S, A, UnknownIfNonSpecific<StateExt>> & Ext;
300 <S, A extends Action, Ext extends {} = {}, StateExt extends {} = {}, PreloadedState = S>(reducer: Reducer<S, A, PreloadedState>, preloadedState?: PreloadedState | undefined, enhancer?: StoreEnhancer<Ext>): Store<S, A, UnknownIfNonSpecific<StateExt>> & Ext;
301}
302/**
303 * A store enhancer is a higher-order function that composes a store creator
304 * to return a new, enhanced store creator. This is similar to middleware in
305 * that it allows you to alter the store interface in a composable way.
306 *
307 * Store enhancers are much the same concept as higher-order components in
308 * React, which are also occasionally called “component enhancers”.
309 *
310 * Because a store is not an instance, but rather a plain-object collection of
311 * functions, copies can be easily created and modified without mutating the
312 * original store. There is an example in `compose` documentation
313 * demonstrating that.
314 *
315 * Most likely you'll never write a store enhancer, but you may use the one
316 * provided by the developer tools. It is what makes time travel possible
317 * without the app being aware it is happening. Amusingly, the Redux
318 * middleware implementation is itself a store enhancer.
319 *
320 * @template Ext Store extension that is mixed into the Store type.
321 * @template StateExt State extension that is mixed into the state type.
322 */
323type StoreEnhancer<Ext extends {} = {}, StateExt extends {} = {}> = <NextExt extends {}, NextStateExt extends {}>(next: StoreEnhancerStoreCreator<NextExt, NextStateExt>) => StoreEnhancerStoreCreator<NextExt & Ext, NextStateExt & StateExt>;
324type StoreEnhancerStoreCreator<Ext extends {} = {}, StateExt extends {} = {}> = <S, A extends Action, PreloadedState>(reducer: Reducer<S, A, PreloadedState>, preloadedState?: PreloadedState | undefined) => Store<S, A, StateExt> & Ext;
325
326/**
327 * @deprecated
328 *
329 * **We recommend using the `configureStore` method
330 * of the `@reduxjs/toolkit` package**, which replaces `createStore`.
331 *
332 * Redux Toolkit is our recommended approach for writing Redux logic today,
333 * including store setup, reducers, data fetching, and more.
334 *
335 * **For more details, please read this Redux docs page:**
336 * **https://redux.js.org/introduction/why-rtk-is-redux-today**
337 *
338 * `configureStore` from Redux Toolkit is an improved version of `createStore` that
339 * simplifies setup and helps avoid common bugs.
340 *
341 * You should not be using the `redux` core package by itself today, except for learning purposes.
342 * The `createStore` method from the core `redux` package will not be removed, but we encourage
343 * all users to migrate to using Redux Toolkit for all Redux code.
344 *
345 * If you want to use `createStore` without this visual deprecation warning, use
346 * the `legacy_createStore` import instead:
347 *
348 * `import { legacy_createStore as createStore} from 'redux'`
349 *
350 */
351declare function createStore<S, A extends Action, Ext extends {} = {}, StateExt extends {} = {}>(reducer: Reducer<S, A>, enhancer?: StoreEnhancer<Ext, StateExt>): Store<S, A, UnknownIfNonSpecific<StateExt>> & Ext;
352/**
353 * @deprecated
354 *
355 * **We recommend using the `configureStore` method
356 * of the `@reduxjs/toolkit` package**, which replaces `createStore`.
357 *
358 * Redux Toolkit is our recommended approach for writing Redux logic today,
359 * including store setup, reducers, data fetching, and more.
360 *
361 * **For more details, please read this Redux docs page:**
362 * **https://redux.js.org/introduction/why-rtk-is-redux-today**
363 *
364 * `configureStore` from Redux Toolkit is an improved version of `createStore` that
365 * simplifies setup and helps avoid common bugs.
366 *
367 * You should not be using the `redux` core package by itself today, except for learning purposes.
368 * The `createStore` method from the core `redux` package will not be removed, but we encourage
369 * all users to migrate to using Redux Toolkit for all Redux code.
370 *
371 * If you want to use `createStore` without this visual deprecation warning, use
372 * the `legacy_createStore` import instead:
373 *
374 * `import { legacy_createStore as createStore} from 'redux'`
375 *
376 */
377declare function createStore<S, A extends Action, Ext extends {} = {}, StateExt extends {} = {}, PreloadedState = S>(reducer: Reducer<S, A, PreloadedState>, preloadedState?: PreloadedState | undefined, enhancer?: StoreEnhancer<Ext, StateExt>): Store<S, A, UnknownIfNonSpecific<StateExt>> & Ext;
378/**
379 * Creates a Redux store that holds the state tree.
380 *
381 * **We recommend using `configureStore` from the
382 * `@reduxjs/toolkit` package**, which replaces `createStore`:
383 * **https://redux.js.org/introduction/why-rtk-is-redux-today**
384 *
385 * The only way to change the data in the store is to call `dispatch()` on it.
386 *
387 * There should only be a single store in your app. To specify how different
388 * parts of the state tree respond to actions, you may combine several reducers
389 * into a single reducer function by using `combineReducers`.
390 *
391 * @param {Function} reducer A function that returns the next state tree, given
392 * the current state tree and the action to handle.
393 *
394 * @param {any} [preloadedState] The initial state. You may optionally specify it
395 * to hydrate the state from the server in universal apps, or to restore a
396 * previously serialized user session.
397 * If you use `combineReducers` to produce the root reducer function, this must be
398 * an object with the same shape as `combineReducers` keys.
399 *
400 * @param {Function} [enhancer] The store enhancer. You may optionally specify it
401 * to enhance the store with third-party capabilities such as middleware,
402 * time travel, persistence, etc. The only store enhancer that ships with Redux
403 * is `applyMiddleware()`.
404 *
405 * @returns {Store} A Redux store that lets you read the state, dispatch actions
406 * and subscribe to changes.
407 */
408declare function legacy_createStore<S, A extends Action, Ext extends {} = {}, StateExt extends {} = {}>(reducer: Reducer<S, A>, enhancer?: StoreEnhancer<Ext, StateExt>): Store<S, A, UnknownIfNonSpecific<StateExt>> & Ext;
409/**
410 * Creates a Redux store that holds the state tree.
411 *
412 * **We recommend using `configureStore` from the
413 * `@reduxjs/toolkit` package**, which replaces `createStore`:
414 * **https://redux.js.org/introduction/why-rtk-is-redux-today**
415 *
416 * The only way to change the data in the store is to call `dispatch()` on it.
417 *
418 * There should only be a single store in your app. To specify how different
419 * parts of the state tree respond to actions, you may combine several reducers
420 * into a single reducer function by using `combineReducers`.
421 *
422 * @param {Function} reducer A function that returns the next state tree, given
423 * the current state tree and the action to handle.
424 *
425 * @param {any} [preloadedState] The initial state. You may optionally specify it
426 * to hydrate the state from the server in universal apps, or to restore a
427 * previously serialized user session.
428 * If you use `combineReducers` to produce the root reducer function, this must be
429 * an object with the same shape as `combineReducers` keys.
430 *
431 * @param {Function} [enhancer] The store enhancer. You may optionally specify it
432 * to enhance the store with third-party capabilities such as middleware,
433 * time travel, persistence, etc. The only store enhancer that ships with Redux
434 * is `applyMiddleware()`.
435 *
436 * @returns {Store} A Redux store that lets you read the state, dispatch actions
437 * and subscribe to changes.
438 */
439declare function legacy_createStore<S, A extends Action, Ext extends {} = {}, StateExt extends {} = {}, PreloadedState = S>(reducer: Reducer<S, A, PreloadedState>, preloadedState?: PreloadedState | undefined, enhancer?: StoreEnhancer<Ext, StateExt>): Store<S, A, UnknownIfNonSpecific<StateExt>> & Ext;
440
441/**
442 * Turns an object whose values are different reducer functions, into a single
443 * reducer function. It will call every child reducer, and gather their results
444 * into a single state object, whose keys correspond to the keys of the passed
445 * reducer functions.
446 *
447 * @template S Combined state object type.
448 *
449 * @param reducers An object whose values correspond to different reducer
450 * functions that need to be combined into one. One handy way to obtain it
451 * is to use `import * as reducers` syntax. The reducers may never
452 * return undefined for any action. Instead, they should return their
453 * initial state if the state passed to them was undefined, and the current
454 * state for any unrecognized action.
455 *
456 * @returns A reducer function that invokes every reducer inside the passed
457 * object, and builds a state object with the same shape.
458 */
459declare function combineReducers<M>(reducers: M): M[keyof M] extends Reducer<any, any, any> | undefined ? Reducer<StateFromReducersMapObject<M>, ActionFromReducersMapObject<M>, Partial<PreloadedStateShapeFromReducersMapObject<M>>> : never;
460
461/**
462 * Turns an object whose values are action creators, into an object with the
463 * same keys, but with every function wrapped into a `dispatch` call so they
464 * may be invoked directly. This is just a convenience method, as you can call
465 * `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
466 *
467 * For convenience, you can also pass an action creator as the first argument,
468 * and get a dispatch wrapped function in return.
469 *
470 * @param actionCreators An object whose values are action
471 * creator functions. One handy way to obtain it is to use `import * as`
472 * syntax. You may also pass a single function.
473 *
474 * @param dispatch The `dispatch` function available on your Redux
475 * store.
476 *
477 * @returns The object mimicking the original object, but with
478 * every action creator wrapped into the `dispatch` call. If you passed a
479 * function as `actionCreators`, the return value will also be a single
480 * function.
481 */
482declare function bindActionCreators<A, C extends ActionCreator<A>>(actionCreator: C, dispatch: Dispatch): C;
483declare function bindActionCreators<A extends ActionCreator<any>, B extends ActionCreator<any>>(actionCreator: A, dispatch: Dispatch): B;
484declare function bindActionCreators<A, M extends ActionCreatorsMapObject<A>>(actionCreators: M, dispatch: Dispatch): M;
485declare function bindActionCreators<M extends ActionCreatorsMapObject, N extends ActionCreatorsMapObject>(actionCreators: M, dispatch: Dispatch): N;
486
487interface MiddlewareAPI<D extends Dispatch = Dispatch, S = any> {
488 dispatch: D;
489 getState(): S;
490}
491/**
492 * A middleware is a higher-order function that composes a dispatch function
493 * to return a new dispatch function. It often turns async actions into
494 * actions.
495 *
496 * Middleware is composable using function composition. It is useful for
497 * logging actions, performing side effects like routing, or turning an
498 * asynchronous API call into a series of synchronous actions.
499 *
500 * @template DispatchExt Extra Dispatch signature added by this middleware.
501 * @template S The type of the state supported by this middleware.
502 * @template D The type of Dispatch of the store where this middleware is
503 * installed.
504 */
505interface Middleware<_DispatchExt = {}, // TODO: see if this can be used in type definition somehow (can't be removed, as is used to get final dispatch type)
506S = any, D extends Dispatch = Dispatch> {
507 (api: MiddlewareAPI<D, S>): (next: (action: unknown) => unknown) => (action: unknown) => unknown;
508}
509
510/**
511 * Creates a store enhancer that applies middleware to the dispatch method
512 * of the Redux store. This is handy for a variety of tasks, such as expressing
513 * asynchronous actions in a concise manner, or logging every action payload.
514 *
515 * See `redux-thunk` package as an example of the Redux middleware.
516 *
517 * Because middleware is potentially asynchronous, this should be the first
518 * store enhancer in the composition chain.
519 *
520 * Note that each middleware will be given the `dispatch` and `getState` functions
521 * as named arguments.
522 *
523 * @param middlewares The middleware chain to be applied.
524 * @returns A store enhancer applying the middleware.
525 *
526 * @template Ext Dispatch signature added by a middleware.
527 * @template S The type of the state supported by a middleware.
528 */
529declare function applyMiddleware(): StoreEnhancer;
530declare function applyMiddleware<Ext1, S>(middleware1: Middleware<Ext1, S, any>): StoreEnhancer<{
531 dispatch: Ext1;
532}>;
533declare function applyMiddleware<Ext1, Ext2, S>(middleware1: Middleware<Ext1, S, any>, middleware2: Middleware<Ext2, S, any>): StoreEnhancer<{
534 dispatch: Ext1 & Ext2;
535}>;
536declare function applyMiddleware<Ext1, Ext2, Ext3, S>(middleware1: Middleware<Ext1, S, any>, middleware2: Middleware<Ext2, S, any>, middleware3: Middleware<Ext3, S, any>): StoreEnhancer<{
537 dispatch: Ext1 & Ext2 & Ext3;
538}>;
539declare function applyMiddleware<Ext1, Ext2, Ext3, Ext4, S>(middleware1: Middleware<Ext1, S, any>, middleware2: Middleware<Ext2, S, any>, middleware3: Middleware<Ext3, S, any>, middleware4: Middleware<Ext4, S, any>): StoreEnhancer<{
540 dispatch: Ext1 & Ext2 & Ext3 & Ext4;
541}>;
542declare function applyMiddleware<Ext1, Ext2, Ext3, Ext4, Ext5, S>(middleware1: Middleware<Ext1, S, any>, middleware2: Middleware<Ext2, S, any>, middleware3: Middleware<Ext3, S, any>, middleware4: Middleware<Ext4, S, any>, middleware5: Middleware<Ext5, S, any>): StoreEnhancer<{
543 dispatch: Ext1 & Ext2 & Ext3 & Ext4 & Ext5;
544}>;
545declare function applyMiddleware<Ext, S = any>(...middlewares: Middleware<any, S, any>[]): StoreEnhancer<{
546 dispatch: Ext;
547}>;
548
549type Func<T extends any[], R> = (...a: T) => R;
550/**
551 * Composes single-argument functions from right to left. The rightmost
552 * function can take multiple arguments as it provides the signature for the
553 * resulting composite function.
554 *
555 * @param funcs The functions to compose.
556 * @returns A function obtained by composing the argument functions from right
557 * to left. For example, `compose(f, g, h)` is identical to doing
558 * `(...args) => f(g(h(...args)))`.
559 */
560declare function compose(): <R>(a: R) => R;
561declare function compose<F extends Function>(f: F): F;
562declare function compose<A, T extends any[], R>(f1: (a: A) => R, f2: Func<T, A>): Func<T, R>;
563declare function compose<A, B, T extends any[], R>(f1: (b: B) => R, f2: (a: A) => B, f3: Func<T, A>): Func<T, R>;
564declare function compose<A, B, C, T extends any[], R>(f1: (c: C) => R, f2: (b: B) => C, f3: (a: A) => B, f4: Func<T, A>): Func<T, R>;
565declare function compose<R>(f1: (a: any) => R, ...funcs: Function[]): (...args: any[]) => R;
566declare function compose<R>(...funcs: Function[]): (...args: any[]) => R;
567
568declare function isAction(action: unknown): action is Action<string>;
569
570/**
571 * @param obj The object to inspect.
572 * @returns True if the argument appears to be a plain object.
573 */
574declare function isPlainObject(obj: any): obj is object;
575
576/**
577 * These are private action types reserved by Redux.
578 * For any unknown actions, you must return the current state.
579 * If the current state is undefined, you must return the initial state.
580 * Do not reference these action types directly in your code.
581 */
582declare const ActionTypes: {
583 INIT: string;
584 REPLACE: string;
585 PROBE_UNKNOWN_ACTION: () => string;
586};
587
588export { Action, ActionCreator, ActionCreatorsMapObject, ActionFromReducer, ActionFromReducersMapObject, AnyAction, Dispatch, Middleware, MiddlewareAPI, Observable, Observer, PreloadedStateShapeFromReducersMapObject, Reducer, ReducerFromReducersMapObject, ReducersMapObject, StateFromReducersMapObject, Store, StoreCreator, StoreEnhancer, StoreEnhancerStoreCreator, UnknownAction, Unsubscribe, ActionTypes as __DO_NOT_USE__ActionTypes, applyMiddleware, bindActionCreators, combineReducers, compose, createStore, isAction, isPlainObject, legacy_createStore };