1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | export interface Action<T = any> {
|
19 | type: T
|
20 | }
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | export interface AnyAction extends Action {
|
29 |
|
30 | [extraProps: string]: any
|
31 | }
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | declare const $CombinedState: unique symbol
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 | interface EmptyObject {
|
55 | readonly [$CombinedState]?: undefined
|
56 | }
|
57 | export type CombinedState<S> = EmptyObject & S
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 | export type PreloadedState<S> = Required<S> extends EmptyObject
|
65 | ? S extends CombinedState<infer S1>
|
66 | ? {
|
67 | [K in keyof S1]?: S1[K] extends object ? PreloadedState<S1[K]> : S1[K]
|
68 | }
|
69 | : S
|
70 | : {
|
71 | [K in keyof S]: S[K] extends string | number | boolean | symbol
|
72 | ? S[K]
|
73 | : PreloadedState<S[K]>
|
74 | }
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 | export type Reducer<S = any, A extends Action = AnyAction> = (
|
103 | state: S | undefined,
|
104 | action: A
|
105 | ) => S
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 | export type ReducersMapObject<S = any, A extends Action = Action> = {
|
113 | [K in keyof S]: Reducer<S[K], A>
|
114 | }
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 | export type StateFromReducersMapObject<M> = M extends ReducersMapObject<
|
122 | any,
|
123 | any
|
124 | >
|
125 | ? { [P in keyof M]: M[P] extends Reducer<infer S, any> ? S : never }
|
126 | : never
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 | export type ReducerFromReducersMapObject<M> = M extends {
|
134 | [P in keyof M]: infer R
|
135 | }
|
136 | ? R extends Reducer<any, any>
|
137 | ? R
|
138 | : never
|
139 | : never
|
140 |
|
141 |
|
142 |
|
143 |
|
144 |
|
145 |
|
146 | export type ActionFromReducer<R> = R extends Reducer<any, infer A> ? A : never
|
147 |
|
148 |
|
149 |
|
150 |
|
151 |
|
152 |
|
153 | export type ActionFromReducersMapObject<M> = M extends ReducersMapObject<
|
154 | any,
|
155 | any
|
156 | >
|
157 | ? ActionFromReducer<ReducerFromReducersMapObject<M>>
|
158 | : never
|
159 |
|
160 |
|
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 |
|
178 | export function combineReducers<S>(
|
179 | reducers: ReducersMapObject<S, any>
|
180 | ): Reducer<CombinedState<S>>
|
181 | export function combineReducers<S, A extends Action = AnyAction>(
|
182 | reducers: ReducersMapObject<S, A>
|
183 | ): Reducer<CombinedState<S>, A>
|
184 | export function combineReducers<M extends ReducersMapObject<any, any>>(
|
185 | reducers: M
|
186 | ): Reducer<
|
187 | CombinedState<StateFromReducersMapObject<M>>,
|
188 | ActionFromReducersMapObject<M>
|
189 | >
|
190 |
|
191 | /* store */
|
192 |
|
193 | /**
|
194 | * A *dispatching function* (or simply *dispatch function*) is a function that
|
195 | * accepts an action or an async action; it then may or may not dispatch one
|
196 | * or more actions to the store.
|
197 | *
|
198 | * We must distinguish between dispatching functions in general and the base
|
199 | * `dispatch` function provided by the store instance without any middleware.
|
200 | *
|
201 | * The base dispatch function *always* synchronously sends an action to the
|
202 | * store's reducer, along with the previous state returned by the store, to
|
203 | * calculate a new state. It expects actions to be plain objects ready to be
|
204 | * consumed by the reducer.
|
205 | *
|
206 | * Middleware wraps the base dispatch function. It allows the dispatch
|
207 | * function to handle async actions in addition to actions. Middleware may
|
208 | * transform, delay, ignore, or otherwise interpret actions or async actions
|
209 | * before passing them to the next middleware.
|
210 | *
|
211 | * @template A The type of things (actions or otherwise) which may be
|
212 | * dispatched.
|
213 | */
|
214 | export interface Dispatch<A extends Action = AnyAction> {
|
215 | <T extends A>(action: T): T
|
216 | }
|
217 |
|
218 | /**
|
219 | * Function to remove listener added by `Store.subscribe()`.
|
220 | */
|
221 | export interface Unsubscribe {
|
222 | (): void
|
223 | }
|
224 |
|
225 | declare global {
|
226 | interface SymbolConstructor {
|
227 | readonly observable: symbol
|
228 | }
|
229 | }
|
230 |
|
231 | /**
|
232 | * A minimal observable of state changes.
|
233 | * For more information, see the observable proposal:
|
234 | * https://github.com/tc39/proposal-observable
|
235 | */
|
236 | export type Observable<T> = {
|
237 | /**
|
238 | * The minimal observable subscription method.
|
239 | * @param {Object} observer Any object that can be used as an observer.
|
240 | * The observer object should have a `next` method.
|
241 | * @returns {subscription} An object with an `unsubscribe` method that can
|
242 | * be used to unsubscribe the observable from the store, and prevent further
|
243 | * emission of values from the observable.
|
244 | */
|
245 | subscribe: (observer: Observer<T>) => { unsubscribe: Unsubscribe }
|
246 | [Symbol.observable](): Observable<T>
|
247 | }
|
248 |
|
249 | /**
|
250 | * An Observer is used to receive data from an Observable, and is supplied as
|
251 | * an argument to subscribe.
|
252 | */
|
253 | export type Observer<T> = {
|
254 | next?(value: T): void
|
255 | }
|
256 |
|
257 |
|
258 |
|
259 |
|
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 | export interface Store<S = any, A extends Action = AnyAction> {
|
266 | |
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 |
|
274 |
|
275 |
|
276 |
|
277 |
|
278 |
|
279 |
|
280 |
|
281 |
|
282 |
|
283 |
|
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 | dispatch: Dispatch<A>
|
293 |
|
294 | |
295 |
|
296 |
|
297 |
|
298 |
|
299 | getState(): S
|
300 |
|
301 | |
302 |
|
303 |
|
304 |
|
305 |
|
306 |
|
307 |
|
308 |
|
309 |
|
310 |
|
311 |
|
312 |
|
313 |
|
314 |
|
315 |
|
316 |
|
317 |
|
318 |
|
319 |
|
320 |
|
321 |
|
322 |
|
323 |
|
324 |
|
325 | subscribe(listener: () => void): Unsubscribe
|
326 |
|
327 | |
328 |
|
329 |
|
330 |
|
331 |
|
332 |
|
333 |
|
334 |
|
335 |
|
336 | replaceReducer(nextReducer: Reducer<S, A>): void
|
337 |
|
338 | |
339 |
|
340 |
|
341 |
|
342 |
|
343 |
|
344 | [Symbol.observable](): Observable<S>
|
345 | }
|
346 |
|
347 | export type DeepPartial<T> = {
|
348 | [K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K]
|
349 | }
|
350 |
|
351 |
|
352 |
|
353 |
|
354 |
|
355 |
|
356 |
|
357 |
|
358 |
|
359 |
|
360 |
|
361 |
|
362 | export interface StoreCreator {
|
363 | <S, A extends Action, Ext, StateExt>(
|
364 | reducer: Reducer<S, A>,
|
365 | enhancer?: StoreEnhancer<Ext, StateExt>
|
366 | ): Store<S & StateExt, A> & Ext
|
367 | <S, A extends Action, Ext, StateExt>(
|
368 | reducer: Reducer<S, A>,
|
369 | preloadedState?: PreloadedState<S>,
|
370 | enhancer?: StoreEnhancer<Ext>
|
371 | ): Store<S & StateExt, A> & Ext
|
372 | }
|
373 |
|
374 |
|
375 |
|
376 |
|
377 |
|
378 |
|
379 |
|
380 |
|
381 |
|
382 |
|
383 |
|
384 |
|
385 |
|
386 |
|
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 |
|
395 |
|
396 |
|
397 |
|
398 |
|
399 | export declare function createStore<S, A extends Action, Ext, StateExt>(
|
400 | reducer: Reducer<S, A>,
|
401 | enhancer?: StoreEnhancer<Ext, StateExt>
|
402 | ): Store<S & StateExt, A> & Ext
|
403 | /**
|
404 | * @deprecated
|
405 | *
|
406 | * **We recommend using the `configureStore` method
|
407 | * of the `@reduxjs/toolkit` package**, which replaces `createStore`.
|
408 | *
|
409 | * Redux Toolkit is our recommended approach for writing Redux logic today,
|
410 | * including store setup, reducers, data fetching, and more.
|
411 | *
|
412 | * **For more details, please read this Redux docs page:**
|
413 | * **https://redux.js.org/introduction/why-rtk-is-redux-today**
|
414 | *
|
415 | * `configureStore` from Redux Toolkit is an improved version of `createStore` that
|
416 | * simplifies setup and helps avoid common bugs.
|
417 | *
|
418 | * You should not be using the `redux` core package by itself today, except for learning purposes.
|
419 | * The `createStore` method from the core `redux` package will not be removed, but we encourage
|
420 | * all users to migrate to using Redux Toolkit for all Redux code.
|
421 | *
|
422 | * If you want to use `createStore` without this visual deprecation warning, use
|
423 | * the `legacy_createStore` import instead:
|
424 | *
|
425 | * `import { legacy_createStore as createStore} from 'redux'`
|
426 | *
|
427 | */
|
428 | export declare function createStore<S, A extends Action, Ext, StateExt>(
|
429 | reducer: Reducer<S, A>,
|
430 | preloadedState?: PreloadedState<S>,
|
431 | enhancer?: StoreEnhancer<Ext>
|
432 | ): Store<S & StateExt, A> & Ext
|
433 |
|
434 | /**
|
435 | * Creates a Redux store that holds the state tree.
|
436 | *
|
437 | * **We recommend using `configureStore` from the
|
438 | * `@reduxjs/toolkit` package**, which replaces `createStore`:
|
439 | * **https://redux.js.org/introduction/why-rtk-is-redux-today**
|
440 | *
|
441 | * The only way to change the data in the store is to call `dispatch()` on it.
|
442 | *
|
443 | * There should only be a single store in your app. To specify how different
|
444 | * parts of the state tree respond to actions, you may combine several reducers
|
445 | * into a single reducer function by using `combineReducers`.
|
446 | *
|
447 | * @param {Function} reducer A function that returns the next state tree, given
|
448 | * the current state tree and the action to handle.
|
449 | *
|
450 | * @param {any} [preloadedState] The initial state. You may optionally specify it
|
451 | * to hydrate the state from the server in universal apps, or to restore a
|
452 | * previously serialized user session.
|
453 | * If you use `combineReducers` to produce the root reducer function, this must be
|
454 | * an object with the same shape as `combineReducers` keys.
|
455 | *
|
456 | * @param {Function} [enhancer] The store enhancer. You may optionally specify it
|
457 | * to enhance the store with third-party capabilities such as middleware,
|
458 | * time travel, persistence, etc. The only store enhancer that ships with Redux
|
459 | * is `applyMiddleware()`.
|
460 | *
|
461 | * @returns {Store} A Redux store that lets you read the state, dispatch actions
|
462 | * and subscribe to changes.
|
463 | */
|
464 | export declare function legacy_createStore<S, A extends Action, Ext, StateExt>(
|
465 | reducer: Reducer<S, A>,
|
466 | enhancer?: StoreEnhancer<Ext, StateExt>
|
467 | ): Store<S & StateExt, A> & Ext
|
468 | /**
|
469 | * Creates a Redux store that holds the state tree.
|
470 | *
|
471 | * **We recommend using `configureStore` from the
|
472 | * `@reduxjs/toolkit` package**, which replaces `createStore`:
|
473 | * **https://redux.js.org/introduction/why-rtk-is-redux-today**
|
474 | *
|
475 | * The only way to change the data in the store is to call `dispatch()` on it.
|
476 | *
|
477 | * There should only be a single store in your app. To specify how different
|
478 | * parts of the state tree respond to actions, you may combine several reducers
|
479 | * into a single reducer function by using `combineReducers`.
|
480 | *
|
481 | * @param {Function} reducer A function that returns the next state tree, given
|
482 | * the current state tree and the action to handle.
|
483 | *
|
484 | * @param {any} [preloadedState] The initial state. You may optionally specify it
|
485 | * to hydrate the state from the server in universal apps, or to restore a
|
486 | * previously serialized user session.
|
487 | * If you use `combineReducers` to produce the root reducer function, this must be
|
488 | * an object with the same shape as `combineReducers` keys.
|
489 | *
|
490 | * @param {Function} [enhancer] The store enhancer. You may optionally specify it
|
491 | * to enhance the store with third-party capabilities such as middleware,
|
492 | * time travel, persistence, etc. The only store enhancer that ships with Redux
|
493 | * is `applyMiddleware()`.
|
494 | *
|
495 | * @returns {Store} A Redux store that lets you read the state, dispatch actions
|
496 | * and subscribe to changes.
|
497 | */
|
498 | export declare function legacy_createStore<S, A extends Action, Ext, StateExt>(
|
499 | reducer: Reducer<S, A>,
|
500 | preloadedState?: PreloadedState<S>,
|
501 | enhancer?: StoreEnhancer<Ext>
|
502 | ): Store<S & StateExt, A> & Ext
|
503 |
|
504 | /**
|
505 | * A store enhancer is a higher-order function that composes a store creator
|
506 | * to return a new, enhanced store creator. This is similar to middleware in
|
507 | * that it allows you to alter the store interface in a composable way.
|
508 | *
|
509 | * Store enhancers are much the same concept as higher-order components in
|
510 | * React, which are also occasionally called “component enhancers”.
|
511 | *
|
512 | * Because a store is not an instance, but rather a plain-object collection of
|
513 | * functions, copies can be easily created and modified without mutating the
|
514 | * original store. There is an example in `compose` documentation
|
515 | * demonstrating that.
|
516 | *
|
517 | * Most likely you'll never write a store enhancer, but you may use the one
|
518 | * provided by the developer tools. It is what makes time travel possible
|
519 | * without the app being aware it is happening. Amusingly, the Redux
|
520 | * middleware implementation is itself a store enhancer.
|
521 | *
|
522 | * @template Ext Store extension that is mixed into the Store type.
|
523 | * @template StateExt State extension that is mixed into the state type.
|
524 | */
|
525 | export type StoreEnhancer<Ext = {}, StateExt = {}> = (
|
526 | next: StoreEnhancerStoreCreator
|
527 | ) => StoreEnhancerStoreCreator<Ext, StateExt>
|
528 | export type StoreEnhancerStoreCreator<Ext = {}, StateExt = {}> = <
|
529 | S = any,
|
530 | A extends Action = AnyAction
|
531 | >(
|
532 | reducer: Reducer<S, A>,
|
533 | preloadedState?: PreloadedState<S>
|
534 | ) => Store<S & StateExt, A> & Ext
|
535 |
|
536 | /* middleware */
|
537 |
|
538 | export interface MiddlewareAPI<D extends Dispatch = Dispatch, S = any> {
|
539 | dispatch: D
|
540 | getState(): S
|
541 | }
|
542 |
|
543 | /**
|
544 | * A middleware is a higher-order function that composes a dispatch function
|
545 | * to return a new dispatch function. It often turns async actions into
|
546 | * actions.
|
547 | *
|
548 | * Middleware is composable using function composition. It is useful for
|
549 | * logging actions, performing side effects like routing, or turning an
|
550 | * asynchronous API call into a series of synchronous actions.
|
551 | *
|
552 | * @template DispatchExt Extra Dispatch signature added by this middleware.
|
553 | * @template S The type of the state supported by this middleware.
|
554 | * @template D The type of Dispatch of the store where this middleware is
|
555 | * installed.
|
556 | */
|
557 | export interface Middleware<
|
558 | DispatchExt = {},
|
559 | S = any,
|
560 | D extends Dispatch = Dispatch
|
561 | > {
|
562 | (api: MiddlewareAPI<D, S>): (
|
563 | next: Dispatch<AnyAction>
|
564 | ) => (action: any) => any
|
565 | }
|
566 |
|
567 | /**
|
568 | * Creates a store enhancer that applies middleware to the dispatch method
|
569 | * of the Redux store. This is handy for a variety of tasks, such as
|
570 | * expressing asynchronous actions in a concise manner, or logging every
|
571 | * action payload.
|
572 | *
|
573 | * See `redux-thunk` package as an example of the Redux middleware.
|
574 | *
|
575 | * Because middleware is potentially asynchronous, this should be the first
|
576 | * store enhancer in the composition chain.
|
577 | *
|
578 | * Note that each middleware will be given the `dispatch` and `getState`
|
579 | * functions as named arguments.
|
580 | *
|
581 | * @param middlewares The middleware chain to be applied.
|
582 | * @returns A store enhancer applying the middleware.
|
583 | *
|
584 | * @template Ext Dispatch signature added by a middleware.
|
585 | * @template S The type of the state supported by a middleware.
|
586 | */
|
587 | export function applyMiddleware(): StoreEnhancer
|
588 | export function applyMiddleware<Ext1, S>(
|
589 | middleware1: Middleware<Ext1, S, any>
|
590 | ): StoreEnhancer<{ dispatch: Ext1 }>
|
591 | export function applyMiddleware<Ext1, Ext2, S>(
|
592 | middleware1: Middleware<Ext1, S, any>,
|
593 | middleware2: Middleware<Ext2, S, any>
|
594 | ): StoreEnhancer<{ dispatch: Ext1 & Ext2 }>
|
595 | export function applyMiddleware<Ext1, Ext2, Ext3, S>(
|
596 | middleware1: Middleware<Ext1, S, any>,
|
597 | middleware2: Middleware<Ext2, S, any>,
|
598 | middleware3: Middleware<Ext3, S, any>
|
599 | ): StoreEnhancer<{ dispatch: Ext1 & Ext2 & Ext3 }>
|
600 | export function applyMiddleware<Ext1, Ext2, Ext3, Ext4, S>(
|
601 | middleware1: Middleware<Ext1, S, any>,
|
602 | middleware2: Middleware<Ext2, S, any>,
|
603 | middleware3: Middleware<Ext3, S, any>,
|
604 | middleware4: Middleware<Ext4, S, any>
|
605 | ): StoreEnhancer<{ dispatch: Ext1 & Ext2 & Ext3 & Ext4 }>
|
606 | export function applyMiddleware<Ext1, Ext2, Ext3, Ext4, Ext5, S>(
|
607 | middleware1: Middleware<Ext1, S, any>,
|
608 | middleware2: Middleware<Ext2, S, any>,
|
609 | middleware3: Middleware<Ext3, S, any>,
|
610 | middleware4: Middleware<Ext4, S, any>,
|
611 | middleware5: Middleware<Ext5, S, any>
|
612 | ): StoreEnhancer<{ dispatch: Ext1 & Ext2 & Ext3 & Ext4 & Ext5 }>
|
613 | export function applyMiddleware<Ext, S = any>(
|
614 | ...middlewares: Middleware<any, S, any>[]
|
615 | ): StoreEnhancer<{ dispatch: Ext }>
|
616 |
|
617 | /* action creators */
|
618 |
|
619 | /**
|
620 | * An *action creator* is, quite simply, a function that creates an action. Do
|
621 | * not confuse the two terms—again, an action is a payload of information, and
|
622 | * an action creator is a factory that creates an action.
|
623 | *
|
624 | * Calling an action creator only produces an action, but does not dispatch
|
625 | * it. You need to call the store's `dispatch` function to actually cause the
|
626 | * mutation. Sometimes we say *bound action creators* to mean functions that
|
627 | * call an action creator and immediately dispatch its result to a specific
|
628 | * store instance.
|
629 | *
|
630 | * If an action creator needs to read the current state, perform an API call,
|
631 | * or cause a side effect, like a routing transition, it should return an
|
632 | * async action instead of an action.
|
633 | *
|
634 | * @template A Returned action type.
|
635 | */
|
636 | export interface ActionCreator<A> {
|
637 | (...args: any[]): A
|
638 | }
|
639 |
|
640 | /**
|
641 | * Object whose values are action creator functions.
|
642 | */
|
643 | export interface ActionCreatorsMapObject<A = any> {
|
644 | [key: string]: ActionCreator<A>
|
645 | }
|
646 |
|
647 | /**
|
648 | * Turns an object whose values are action creators, into an object with the
|
649 | * same keys, but with every function wrapped into a `dispatch` call so they
|
650 | * may be invoked directly. This is just a convenience method, as you can call
|
651 | * `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
|
652 | *
|
653 | * For convenience, you can also pass a single function as the first argument,
|
654 | * and get a function in return.
|
655 | *
|
656 | * @param actionCreator An object whose values are action creator functions.
|
657 | * One handy way to obtain it is to use ES6 `import * as` syntax. You may
|
658 | * also pass a single function.
|
659 | *
|
660 | * @param dispatch The `dispatch` function available on your Redux store.
|
661 | *
|
662 | * @returns The object mimicking the original object, but with every action
|
663 | * creator wrapped into the `dispatch` call. If you passed a function as
|
664 | * `actionCreator`, the return value will also be a single function.
|
665 | */
|
666 | export function bindActionCreators<A, C extends ActionCreator<A>>(
|
667 | actionCreator: C,
|
668 | dispatch: Dispatch
|
669 | ): C
|
670 |
|
671 | export function bindActionCreators<
|
672 | A extends ActionCreator<any>,
|
673 | B extends ActionCreator<any>
|
674 | >(actionCreator: A, dispatch: Dispatch): B
|
675 |
|
676 | export function bindActionCreators<A, M extends ActionCreatorsMapObject<A>>(
|
677 | actionCreators: M,
|
678 | dispatch: Dispatch
|
679 | ): M
|
680 |
|
681 | export function bindActionCreators<
|
682 | M extends ActionCreatorsMapObject<any>,
|
683 | N extends ActionCreatorsMapObject<any>
|
684 | >(actionCreators: M, dispatch: Dispatch): N
|
685 |
|
686 | /* compose */
|
687 |
|
688 | type Func0<R> = () => R
|
689 | type Func1<T1, R> = (a1: T1) => R
|
690 | type Func2<T1, T2, R> = (a1: T1, a2: T2) => R
|
691 | type Func3<T1, T2, T3, R> = (a1: T1, a2: T2, a3: T3, ...args: any[]) => R
|
692 |
|
693 | /**
|
694 | * Composes single-argument functions from right to left. The rightmost
|
695 | * function can take multiple arguments as it provides the signature for the
|
696 | * resulting composite function.
|
697 | *
|
698 | * @param funcs The functions to compose.
|
699 | * @returns R function obtained by composing the argument functions from right
|
700 | * to left. For example, `compose(f, g, h)` is identical to doing
|
701 | * `(...args) => f(g(h(...args)))`.
|
702 | */
|
703 | export function compose(): <R>(a: R) => R
|
704 |
|
705 | export function compose<F extends Function>(f: F): F
|
706 |
|
707 | /* two functions */
|
708 | export function compose<A, R>(f1: (b: A) => R, f2: Func0<A>): Func0<R>
|
709 | export function compose<A, T1, R>(
|
710 | f1: (b: A) => R,
|
711 | f2: Func1<T1, A>
|
712 | ): Func1<T1, R>
|
713 | export function compose<A, T1, T2, R>(
|
714 | f1: (b: A) => R,
|
715 | f2: Func2<T1, T2, A>
|
716 | ): Func2<T1, T2, R>
|
717 | export function compose<A, T1, T2, T3, R>(
|
718 | f1: (b: A) => R,
|
719 | f2: Func3<T1, T2, T3, A>
|
720 | ): Func3<T1, T2, T3, R>
|
721 |
|
722 | /* three functions */
|
723 | export function compose<A, B, R>(
|
724 | f1: (b: B) => R,
|
725 | f2: (a: A) => B,
|
726 | f3: Func0<A>
|
727 | ): Func0<R>
|
728 | export function compose<A, B, T1, R>(
|
729 | f1: (b: B) => R,
|
730 | f2: (a: A) => B,
|
731 | f3: Func1<T1, A>
|
732 | ): Func1<T1, R>
|
733 | export function compose<A, B, T1, T2, R>(
|
734 | f1: (b: B) => R,
|
735 | f2: (a: A) => B,
|
736 | f3: Func2<T1, T2, A>
|
737 | ): Func2<T1, T2, R>
|
738 | export function compose<A, B, T1, T2, T3, R>(
|
739 | f1: (b: B) => R,
|
740 | f2: (a: A) => B,
|
741 | f3: Func3<T1, T2, T3, A>
|
742 | ): Func3<T1, T2, T3, R>
|
743 |
|
744 | /* four functions */
|
745 | export function compose<A, B, C, R>(
|
746 | f1: (b: C) => R,
|
747 | f2: (a: B) => C,
|
748 | f3: (a: A) => B,
|
749 | f4: Func0<A>
|
750 | ): Func0<R>
|
751 | export function compose<A, B, C, T1, R>(
|
752 | f1: (b: C) => R,
|
753 | f2: (a: B) => C,
|
754 | f3: (a: A) => B,
|
755 | f4: Func1<T1, A>
|
756 | ): Func1<T1, R>
|
757 | export function compose<A, B, C, T1, T2, R>(
|
758 | f1: (b: C) => R,
|
759 | f2: (a: B) => C,
|
760 | f3: (a: A) => B,
|
761 | f4: Func2<T1, T2, A>
|
762 | ): Func2<T1, T2, R>
|
763 | export function compose<A, B, C, T1, T2, T3, R>(
|
764 | f1: (b: C) => R,
|
765 | f2: (a: B) => C,
|
766 | f3: (a: A) => B,
|
767 | f4: Func3<T1, T2, T3, A>
|
768 | ): Func3<T1, T2, T3, R>
|
769 |
|
770 | /* rest */
|
771 | export function compose<R>(
|
772 | f1: (b: any) => R,
|
773 | ...funcs: Function[]
|
774 | ): (...args: any[]) => R
|
775 |
|
776 | export function compose<R>(...funcs: Function[]): (...args: any[]) => R
|
777 |
|
\ | No newline at end of file |