1
-
2
1
/**
3
2
* An *action* is a plain object that represents an intention to change the
4
3
* state. Actions are the only way to get data into the store. Any data,
17
16
* @template T the type of the action's `type` tag.
18
17
*/
19
18
export interface Action < T = any > {
20
- type : T ;
19
+ type : T
21
20
}
22
21
23
22
/**
@@ -27,7 +26,7 @@ export interface Action<T = any> {
27
26
*/
28
27
export interface AnyAction extends Action {
29
28
// Allows any extra properties to be defined in an action.
30
- [ extraProps : string ] : any ;
29
+ [ extraProps : string ] : any
31
30
}
32
31
33
32
/* reducers */
@@ -56,15 +55,18 @@ export interface AnyAction extends Action {
56
55
* @template S The type of state consumed and produced by this reducer.
57
56
* @template A The type of actions the reducer can potentially respond to.
58
57
*/
59
- export type Reducer < S = any , A extends Action = AnyAction > = ( state : S | undefined , action : A ) => S ;
58
+ export type Reducer < S = any , A extends Action = AnyAction > = (
59
+ state : S | undefined ,
60
+ action : A
61
+ ) => S
60
62
61
63
/**
62
64
* Object whose values correspond to different reducer functions.
63
65
*
64
66
* @template A The type of actions the reducers can potentially respond to.
65
67
*/
66
68
export type ReducersMapObject < S = any , A extends Action = Action > = {
67
- [ K in keyof S ] : Reducer < S [ K ] , A > ;
69
+ [ K in keyof S ] : Reducer < S [ K ] , A >
68
70
}
69
71
70
72
/**
@@ -85,9 +87,12 @@ export type ReducersMapObject<S = any, A extends Action = Action> = {
85
87
* @returns A reducer function that invokes every reducer inside the passed
86
88
* object, and builds a state object with the same shape.
87
89
*/
88
- export function combineReducers < S > ( reducers : ReducersMapObject < S , any > ) : Reducer < S > ;
89
- export function combineReducers < S , A extends Action = AnyAction > ( reducers : ReducersMapObject < S , A > ) : Reducer < S , A > ;
90
-
90
+ export function combineReducers < S > (
91
+ reducers : ReducersMapObject < S , any >
92
+ ) : Reducer < S >
93
+ export function combineReducers < S , A extends Action = AnyAction > (
94
+ reducers : ReducersMapObject < S , A >
95
+ ) : Reducer < S , A >
91
96
92
97
/* store */
93
98
@@ -113,14 +118,14 @@ export function combineReducers<S, A extends Action = AnyAction>(reducers: Reduc
113
118
* dispatched.
114
119
*/
115
120
export interface Dispatch < A extends Action = AnyAction > {
116
- < T extends A > ( action : T ) : T ;
121
+ < T extends A > ( action : T ) : T
117
122
}
118
123
119
124
/**
120
125
* Function to remove listener added by `Store.subscribe()`.
121
126
*/
122
127
export interface Unsubscribe {
123
- ( ) : void ;
128
+ ( ) : void
124
129
}
125
130
126
131
/**
@@ -158,14 +163,14 @@ export interface Store<S = any, A extends Action = AnyAction> {
158
163
* Note that, if you use a custom middleware, it may wrap `dispatch()` to
159
164
* return something else (for example, a Promise you can await).
160
165
*/
161
- dispatch : Dispatch < A > ;
166
+ dispatch : Dispatch < A >
162
167
163
168
/**
164
169
* Reads the state tree managed by the store.
165
170
*
166
171
* @returns The current state tree of your application.
167
172
*/
168
- getState ( ) : S ;
173
+ getState ( ) : S
169
174
170
175
/**
171
176
* Adds a change listener. It will be called any time an action is
@@ -191,7 +196,7 @@ export interface Store<S = any, A extends Action = AnyAction> {
191
196
* @param listener A callback to be invoked on every dispatch.
192
197
* @returns A function to remove this change listener.
193
198
*/
194
- subscribe ( listener : ( ) => void ) : Unsubscribe ;
199
+ subscribe ( listener : ( ) => void ) : Unsubscribe
195
200
196
201
/**
197
202
* Replaces the reducer currently used by the store to calculate the state.
@@ -202,10 +207,10 @@ export interface Store<S = any, A extends Action = AnyAction> {
202
207
*
203
208
* @param nextReducer The reducer for the store to use instead.
204
209
*/
205
- replaceReducer ( nextReducer : Reducer < S , A > ) : void ;
210
+ replaceReducer ( nextReducer : Reducer < S , A > ) : void
206
211
}
207
212
208
- export type DeepPartial < T > = { [ K in keyof T ] ?: DeepPartial < T [ K ] > } ;
213
+ export type DeepPartial < T > = { [ K in keyof T ] ?: DeepPartial < T [ K ] > }
209
214
210
215
/**
211
216
* A store creator is a function that creates a Redux store. Like with
@@ -219,8 +224,15 @@ export type DeepPartial<T> = { [K in keyof T]?: DeepPartial<T[K]> };
219
224
* @template StateExt State extension that is mixed into the state type.
220
225
*/
221
226
export interface StoreCreator {
222
- < S , A extends Action , Ext , StateExt > ( reducer : Reducer < S , A > , enhancer ?: StoreEnhancer < Ext , StateExt > ) : Store < S & StateExt , A > & Ext ;
223
- < S , A extends Action , Ext , StateExt > ( reducer : Reducer < S , A > , preloadedState ?: DeepPartial < S > , enhancer ?: StoreEnhancer < Ext > ) : Store < S & StateExt , A > & Ext ;
227
+ < S , A extends Action , Ext , StateExt > (
228
+ reducer : Reducer < S , A > ,
229
+ enhancer ?: StoreEnhancer < Ext , StateExt >
230
+ ) : Store < S & StateExt , A > & Ext
231
+ < S , A extends Action , Ext , StateExt > (
232
+ reducer : Reducer < S , A > ,
233
+ preloadedState ?: DeepPartial < S > ,
234
+ enhancer ?: StoreEnhancer < Ext >
235
+ ) : Store < S & StateExt , A > & Ext
224
236
}
225
237
226
238
/**
@@ -251,7 +263,7 @@ export interface StoreCreator {
251
263
* @returns A Redux store that lets you read the state, dispatch actions and
252
264
* subscribe to changes.
253
265
*/
254
- export const createStore : StoreCreator ;
266
+ export const createStore : StoreCreator
255
267
256
268
/**
257
269
* A store enhancer is a higher-order function that composes a store creator
@@ -274,15 +286,22 @@ export const createStore: StoreCreator;
274
286
* @template Ext Store extension that is mixed into the Store type.
275
287
* @template StateExt State extension that is mixed into the state type.
276
288
*/
277
- export type StoreEnhancer < Ext = { } , StateExt = { } > = ( next : StoreEnhancerStoreCreator ) => StoreEnhancerStoreCreator < Ext , StateExt > ;
278
- export type StoreEnhancerStoreCreator < Ext = { } , StateExt = { } > = < S = any , A extends Action = AnyAction > ( reducer : Reducer < S , A > , preloadedState ?: DeepPartial < S > ) => Store < S & StateExt , A > & Ext ;
279
-
289
+ export type StoreEnhancer < Ext = { } , StateExt = { } > = (
290
+ next : StoreEnhancerStoreCreator
291
+ ) => StoreEnhancerStoreCreator < Ext , StateExt >
292
+ export type StoreEnhancerStoreCreator < Ext = { } , StateExt = { } > = <
293
+ S = any ,
294
+ A extends Action = AnyAction
295
+ > (
296
+ reducer : Reducer < S , A > ,
297
+ preloadedState ?: DeepPartial < S >
298
+ ) => Store < S & StateExt , A > & Ext
280
299
281
300
/* middleware */
282
301
283
302
export interface MiddlewareAPI < D extends Dispatch = Dispatch , S = any > {
284
- dispatch : D ;
285
- getState ( ) : S ;
303
+ dispatch : D
304
+ getState ( ) : S
286
305
}
287
306
288
307
/**
@@ -299,8 +318,14 @@ export interface MiddlewareAPI<D extends Dispatch = Dispatch, S = any> {
299
318
* @template D The type of Dispatch of the store where this middleware is
300
319
* installed.
301
320
*/
302
- export interface Middleware < DispatchExt = { } , S = any , D extends Dispatch = Dispatch > {
303
- ( api : MiddlewareAPI < D , S > ) : ( next : Dispatch < AnyAction > ) => ( action : any ) => any ;
321
+ export interface Middleware <
322
+ DispatchExt = { } ,
323
+ S = any ,
324
+ D extends Dispatch = Dispatch
325
+ > {
326
+ ( api : MiddlewareAPI < D , S > ) : (
327
+ next : Dispatch < AnyAction >
328
+ ) => ( action : any ) => any
304
329
}
305
330
306
331
/**
@@ -323,14 +348,35 @@ export interface Middleware<DispatchExt = {}, S = any, D extends Dispatch = Disp
323
348
* @template Ext Dispatch signature added by a middleware.
324
349
* @template S The type of the state supported by a middleware.
325
350
*/
326
- export function applyMiddleware ( ) : StoreEnhancer ;
327
- export function applyMiddleware < Ext1 , S > ( middleware1 : Middleware < Ext1 , S , any > ) : StoreEnhancer < { dispatch : Ext1 } > ;
328
- export function applyMiddleware < Ext1 , Ext2 , S > ( middleware1 : Middleware < Ext1 , S , any > , middleware2 : Middleware < Ext2 , S , any > ) : StoreEnhancer < { dispatch : Ext1 & Ext2 } > ;
329
- export function applyMiddleware < Ext1 , Ext2 , Ext3 , S > ( middleware1 : Middleware < Ext1 , S , any > , middleware2 : Middleware < Ext2 , S , any > , middleware3 : Middleware < Ext3 , S , any > ) : StoreEnhancer < { dispatch : Ext1 & Ext2 & Ext3 } > ;
330
- export 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 < { dispatch : Ext1 & Ext2 & Ext3 & Ext4 } > ;
331
- export 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 < { dispatch : Ext1 & Ext2 & Ext3 & Ext4 & Ext5 } > ;
332
- export function applyMiddleware < Ext , S = any > ( ...middlewares : Middleware < any , S , any > [ ] ) : StoreEnhancer < { dispatch : Ext } > ;
333
-
351
+ export function applyMiddleware ( ) : StoreEnhancer
352
+ export function applyMiddleware < Ext1 , S > (
353
+ middleware1 : Middleware < Ext1 , S , any >
354
+ ) : StoreEnhancer < { dispatch : Ext1 } >
355
+ export function applyMiddleware < Ext1 , Ext2 , S > (
356
+ middleware1 : Middleware < Ext1 , S , any > ,
357
+ middleware2 : Middleware < Ext2 , S , any >
358
+ ) : StoreEnhancer < { dispatch : Ext1 & Ext2 } >
359
+ export function applyMiddleware < Ext1 , Ext2 , Ext3 , S > (
360
+ middleware1 : Middleware < Ext1 , S , any > ,
361
+ middleware2 : Middleware < Ext2 , S , any > ,
362
+ middleware3 : Middleware < Ext3 , S , any >
363
+ ) : StoreEnhancer < { dispatch : Ext1 & Ext2 & Ext3 } >
364
+ export function applyMiddleware < Ext1 , Ext2 , Ext3 , Ext4 , S > (
365
+ middleware1 : Middleware < Ext1 , S , any > ,
366
+ middleware2 : Middleware < Ext2 , S , any > ,
367
+ middleware3 : Middleware < Ext3 , S , any > ,
368
+ middleware4 : Middleware < Ext4 , S , any >
369
+ ) : StoreEnhancer < { dispatch : Ext1 & Ext2 & Ext3 & Ext4 } >
370
+ export function applyMiddleware < Ext1 , Ext2 , Ext3 , Ext4 , Ext5 , S > (
371
+ middleware1 : Middleware < Ext1 , S , any > ,
372
+ middleware2 : Middleware < Ext2 , S , any > ,
373
+ middleware3 : Middleware < Ext3 , S , any > ,
374
+ middleware4 : Middleware < Ext4 , S , any > ,
375
+ middleware5 : Middleware < Ext5 , S , any >
376
+ ) : StoreEnhancer < { dispatch : Ext1 & Ext2 & Ext3 & Ext4 & Ext5 } >
377
+ export function applyMiddleware < Ext , S = any > (
378
+ ...middlewares : Middleware < any , S , any > [ ]
379
+ ) : StoreEnhancer < { dispatch : Ext } >
334
380
335
381
/* action creators */
336
382
@@ -352,14 +398,14 @@ export function applyMiddleware<Ext, S = any>(...middlewares: Middleware<any, S,
352
398
* @template A Returned action type.
353
399
*/
354
400
export interface ActionCreator < A > {
355
- ( ...args : any [ ] ) : A ;
401
+ ( ...args : any [ ] ) : A
356
402
}
357
403
358
404
/**
359
405
* Object whose values are action creator functions.
360
406
*/
361
407
export interface ActionCreatorsMapObject < A = any > {
362
- [ key : string ] : ActionCreator < A > ;
408
+ [ key : string ] : ActionCreator < A >
363
409
}
364
410
365
411
/**
@@ -381,27 +427,32 @@ export interface ActionCreatorsMapObject<A = any> {
381
427
* creator wrapped into the `dispatch` call. If you passed a function as
382
428
* `actionCreator`, the return value will also be a single function.
383
429
*/
384
- export function bindActionCreators < A , C extends ActionCreator < A > > ( actionCreator : C , dispatch : Dispatch ) : C ;
430
+ export function bindActionCreators < A , C extends ActionCreator < A > > (
431
+ actionCreator : C ,
432
+ dispatch : Dispatch
433
+ ) : C
385
434
386
435
export function bindActionCreators <
387
436
A extends ActionCreator < any > ,
388
437
B extends ActionCreator < any >
389
- > ( actionCreator : A , dispatch : Dispatch ) : B ;
438
+ > ( actionCreator : A , dispatch : Dispatch ) : B
390
439
391
- export function bindActionCreators < A , M extends ActionCreatorsMapObject < A > > ( actionCreators : M , dispatch : Dispatch ) : M ;
440
+ export function bindActionCreators < A , M extends ActionCreatorsMapObject < A > > (
441
+ actionCreators : M ,
442
+ dispatch : Dispatch
443
+ ) : M
392
444
393
445
export function bindActionCreators <
394
446
M extends ActionCreatorsMapObject < any > ,
395
447
N extends ActionCreatorsMapObject < any >
396
- > ( actionCreators : M , dispatch : Dispatch ) : N ;
397
-
448
+ > ( actionCreators : M , dispatch : Dispatch ) : N
398
449
399
450
/* compose */
400
451
401
- type Func0 < R > = ( ) => R ;
402
- type Func1 < T1 , R > = ( a1 : T1 ) => R ;
403
- type Func2 < T1 , T2 , R > = ( a1 : T1 , a2 : T2 ) => R ;
404
- type Func3 < T1 , T2 , T3 , R > = ( a1 : T1 , a2 : T2 , a3 : T3 , ...args : any [ ] ) => R ;
452
+ type Func0 < R > = ( ) => R
453
+ type Func1 < T1 , R > = ( a1 : T1 ) => R
454
+ type Func2 < T1 , T2 , R > = ( a1 : T1 , a2 : T2 ) => R
455
+ type Func3 < T1 , T2 , T3 , R > = ( a1 : T1 , a2 : T2 , a3 : T3 , ...args : any [ ] ) => R
405
456
406
457
/**
407
458
* Composes single-argument functions from right to left. The rightmost
@@ -413,55 +464,77 @@ type Func3<T1, T2, T3, R> = (a1: T1, a2: T2, a3: T3, ...args: any[]) => R;
413
464
* to left. For example, `compose(f, g, h)` is identical to doing
414
465
* `(...args) => f(g(h(...args)))`.
415
466
*/
416
- export function compose ( ) : < R > ( a : R ) => R ;
467
+ export function compose ( ) : < R > ( a : R ) => R
417
468
418
- export function compose < F extends Function > ( f : F ) : F ;
469
+ export function compose < F extends Function > ( f : F ) : F
419
470
420
471
/* two functions */
421
- export function compose < A , R > (
422
- f1 : ( b : A ) => R , f2 : Func0 < A >
423
- ) : Func0 < R > ;
472
+ export function compose < A , R > ( f1 : ( b : A ) => R , f2 : Func0 < A > ) : Func0 < R >
424
473
export function compose < A , T1 , R > (
425
- f1 : ( b : A ) => R , f2 : Func1 < T1 , A >
426
- ) : Func1 < T1 , R > ;
474
+ f1 : ( b : A ) => R ,
475
+ f2 : Func1 < T1 , A >
476
+ ) : Func1 < T1 , R >
427
477
export function compose < A , T1 , T2 , R > (
428
- f1 : ( b : A ) => R , f2 : Func2 < T1 , T2 , A >
429
- ) : Func2 < T1 , T2 , R > ;
478
+ f1 : ( b : A ) => R ,
479
+ f2 : Func2 < T1 , T2 , A >
480
+ ) : Func2 < T1 , T2 , R >
430
481
export function compose < A , T1 , T2 , T3 , R > (
431
- f1 : ( b : A ) => R , f2 : Func3 < T1 , T2 , T3 , A >
432
- ) : Func3 < T1 , T2 , T3 , R > ;
482
+ f1 : ( b : A ) => R ,
483
+ f2 : Func3 < T1 , T2 , T3 , A >
484
+ ) : Func3 < T1 , T2 , T3 , R >
433
485
434
486
/* three functions */
435
487
export function compose < A , B , R > (
436
- f1 : ( b : B ) => R , f2 : ( a : A ) => B , f3 : Func0 < A >
437
- ) : Func0 < R > ;
488
+ f1 : ( b : B ) => R ,
489
+ f2 : ( a : A ) => B ,
490
+ f3 : Func0 < A >
491
+ ) : Func0 < R >
438
492
export function compose < A , B , T1 , R > (
439
- f1 : ( b : B ) => R , f2 : ( a : A ) => B , f3 : Func1 < T1 , A >
440
- ) : Func1 < T1 , R > ;
493
+ f1 : ( b : B ) => R ,
494
+ f2 : ( a : A ) => B ,
495
+ f3 : Func1 < T1 , A >
496
+ ) : Func1 < T1 , R >
441
497
export function compose < A , B , T1 , T2 , R > (
442
- f1 : ( b : B ) => R , f2 : ( a : A ) => B , f3 : Func2 < T1 , T2 , A >
443
- ) : Func2 < T1 , T2 , R > ;
498
+ f1 : ( b : B ) => R ,
499
+ f2 : ( a : A ) => B ,
500
+ f3 : Func2 < T1 , T2 , A >
501
+ ) : Func2 < T1 , T2 , R >
444
502
export function compose < A , B , T1 , T2 , T3 , R > (
445
- f1 : ( b : B ) => R , f2 : ( a : A ) => B , f3 : Func3 < T1 , T2 , T3 , A >
446
- ) : Func3 < T1 , T2 , T3 , R > ;
503
+ f1 : ( b : B ) => R ,
504
+ f2 : ( a : A ) => B ,
505
+ f3 : Func3 < T1 , T2 , T3 , A >
506
+ ) : Func3 < T1 , T2 , T3 , R >
447
507
448
508
/* four functions */
449
509
export function compose < A , B , C , R > (
450
- f1 : ( b : C ) => R , f2 : ( a : B ) => C , f3 : ( a : A ) => B , f4 : Func0 < A >
451
- ) : Func0 < R > ;
510
+ f1 : ( b : C ) => R ,
511
+ f2 : ( a : B ) => C ,
512
+ f3 : ( a : A ) => B ,
513
+ f4 : Func0 < A >
514
+ ) : Func0 < R >
452
515
export function compose < A , B , C , T1 , R > (
453
- f1 : ( b : C ) => R , f2 : ( a : B ) => C , f3 : ( a : A ) => B , f4 : Func1 < T1 , A >
454
- ) : Func1 < T1 , R > ;
516
+ f1 : ( b : C ) => R ,
517
+ f2 : ( a : B ) => C ,
518
+ f3 : ( a : A ) => B ,
519
+ f4 : Func1 < T1 , A >
520
+ ) : Func1 < T1 , R >
455
521
export function compose < A , B , C , T1 , T2 , R > (
456
- f1 : ( b : C ) => R , f2 : ( a : B ) => C , f3 : ( a : A ) => B , f4 : Func2 < T1 , T2 , A >
457
- ) : Func2 < T1 , T2 , R > ;
522
+ f1 : ( b : C ) => R ,
523
+ f2 : ( a : B ) => C ,
524
+ f3 : ( a : A ) => B ,
525
+ f4 : Func2 < T1 , T2 , A >
526
+ ) : Func2 < T1 , T2 , R >
458
527
export function compose < A , B , C , T1 , T2 , T3 , R > (
459
- f1 : ( b : C ) => R , f2 : ( a : B ) => C , f3 : ( a : A ) => B , f4 : Func3 < T1 , T2 , T3 , A >
460
- ) : Func3 < T1 , T2 , T3 , R > ;
528
+ f1 : ( b : C ) => R ,
529
+ f2 : ( a : B ) => C ,
530
+ f3 : ( a : A ) => B ,
531
+ f4 : Func3 < T1 , T2 , T3 , A >
532
+ ) : Func3 < T1 , T2 , T3 , R >
461
533
462
534
/* rest */
463
535
export function compose < R > (
464
- f1 : ( b : any ) => R , ...funcs : Function [ ]
465
- ) : ( ...args : any [ ] ) => R ;
536
+ f1 : ( b : any ) => R ,
537
+ ...funcs : Function [ ]
538
+ ) : ( ...args : any [ ] ) => R
466
539
467
- export function compose < R > ( ...funcs : Function [ ] ) : ( ...args : any [ ] ) => R ;
540
+ export function compose < R > ( ...funcs : Function [ ] ) : ( ...args : any [ ] ) => R
0 commit comments