@@ -260,183 +260,163 @@ export interface ConnectOptions<
260
260
) => boolean
261
261
}
262
262
263
- /* @public */
264
- function connect ( ) : InferableComponentEnhancer < DispatchProp >
263
+ /**
264
+ * Connects a React component to a Redux store.
265
+ *
266
+ * - Without arguments, just wraps the component, without changing the behavior / props
267
+ *
268
+ * - If 2 params are passed (3rd param, mergeProps, is skipped), default behavior
269
+ * is to override ownProps (as stated in the docs), so what remains is everything that's
270
+ * not a state or dispatch prop
271
+ *
272
+ * - When 3rd param is passed, we don't know if ownProps propagate and whether they
273
+ * should be valid component props, because it depends on mergeProps implementation.
274
+ * As such, it is the user's responsibility to extend ownProps interface from state or
275
+ * dispatch props or both when applicable
276
+ *
277
+ * @param mapStateToProps
278
+ * @param mapDispatchToProps
279
+ * @param mergeProps
280
+ * @param options
281
+ */
282
+ export interface Connect < DefaultState = DefaultRootState > {
283
+ // tslint:disable:no-unnecessary-generics
284
+ ( ) : InferableComponentEnhancer < DispatchProp >
285
+
286
+ /** mapState only */
287
+ < TStateProps = { } , no_dispatch = { } , TOwnProps = { } , State = DefaultState > (
288
+ mapStateToProps : MapStateToPropsParam < TStateProps , TOwnProps , State >
289
+ ) : InferableComponentEnhancerWithProps < TStateProps & DispatchProp , TOwnProps >
290
+
291
+ /** mapDispatch only (as a function) */
292
+ < no_state = { } , TDispatchProps = { } , TOwnProps = { } > (
293
+ mapStateToProps : null | undefined ,
294
+ mapDispatchToProps : MapDispatchToPropsNonObject < TDispatchProps , TOwnProps >
295
+ ) : InferableComponentEnhancerWithProps < TDispatchProps , TOwnProps >
296
+
297
+ /** mapDispatch only (as an object) */
298
+ < no_state = { } , TDispatchProps = { } , TOwnProps = { } > (
299
+ mapStateToProps : null | undefined ,
300
+ mapDispatchToProps : MapDispatchToPropsParam < TDispatchProps , TOwnProps >
301
+ ) : InferableComponentEnhancerWithProps <
302
+ ResolveThunks < TDispatchProps > ,
303
+ TOwnProps
304
+ >
265
305
266
- /* @public */
267
- function connect <
268
- TStateProps = { } ,
269
- no_dispatch = { } ,
270
- TOwnProps = { } ,
271
- State = DefaultRootState
272
- > (
273
- mapStateToProps : MapStateToPropsParam < TStateProps , TOwnProps , State >
274
- ) : InferableComponentEnhancerWithProps <
275
- TStateProps & DispatchProp ,
276
- TOwnProps & ConnectProps
277
- >
278
-
279
- /* @public */
280
- function connect < no_state = { } , TDispatchProps = { } , TOwnProps = { } > (
281
- mapStateToProps : null | undefined ,
282
- mapDispatchToProps : MapDispatchToPropsNonObject < TDispatchProps , TOwnProps >
283
- ) : InferableComponentEnhancerWithProps < TDispatchProps , TOwnProps & ConnectProps >
284
-
285
- /* @public */
286
- function connect < no_state = { } , TDispatchProps = { } , TOwnProps = { } > (
287
- mapStateToProps : null | undefined ,
288
- mapDispatchToProps : MapDispatchToPropsParam < TDispatchProps , TOwnProps >
289
- ) : InferableComponentEnhancerWithProps <
290
- ResolveThunks < TDispatchProps > ,
291
- TOwnProps & ConnectProps
292
- >
293
-
294
- /* @public */
295
- function connect <
296
- TStateProps = { } ,
297
- TDispatchProps = { } ,
298
- TOwnProps = { } ,
299
- State = DefaultRootState
300
- > (
301
- mapStateToProps : MapStateToPropsParam < TStateProps , TOwnProps , State > ,
302
- mapDispatchToProps : MapDispatchToPropsNonObject < TDispatchProps , TOwnProps >
303
- ) : InferableComponentEnhancerWithProps <
304
- TStateProps & TDispatchProps ,
305
- TOwnProps & ConnectProps
306
- >
307
-
308
- /* @public */
309
- function connect <
310
- TStateProps = { } ,
311
- TDispatchProps = { } ,
312
- TOwnProps = { } ,
313
- State = DefaultRootState
314
- > (
315
- mapStateToProps : MapStateToPropsParam < TStateProps , TOwnProps , State > ,
316
- mapDispatchToProps : MapDispatchToPropsParam < TDispatchProps , TOwnProps >
317
- ) : InferableComponentEnhancerWithProps <
318
- TStateProps & ResolveThunks < TDispatchProps > ,
319
- TOwnProps & ConnectProps
320
- >
321
-
322
- /* @public */
323
- function connect <
324
- no_state = { } ,
325
- no_dispatch = { } ,
326
- TOwnProps = { } ,
327
- TMergedProps = { }
328
- > (
329
- mapStateToProps : null | undefined ,
330
- mapDispatchToProps : null | undefined ,
331
- mergeProps : MergeProps < undefined , undefined , TOwnProps , TMergedProps >
332
- ) : InferableComponentEnhancerWithProps < TMergedProps , TOwnProps & ConnectProps >
306
+ /** mapState and mapDispatch (as a function)*/
307
+ < TStateProps = { } , TDispatchProps = { } , TOwnProps = { } , State = DefaultState > (
308
+ mapStateToProps : MapStateToPropsParam < TStateProps , TOwnProps , State > ,
309
+ mapDispatchToProps : MapDispatchToPropsNonObject < TDispatchProps , TOwnProps >
310
+ ) : InferableComponentEnhancerWithProps <
311
+ TStateProps & TDispatchProps ,
312
+ TOwnProps
313
+ >
333
314
334
- /* @public */
335
- function connect <
336
- TStateProps = { } ,
337
- no_dispatch = { } ,
338
- TOwnProps = { } ,
339
- TMergedProps = { } ,
340
- State = DefaultRootState
341
- > (
342
- mapStateToProps : MapStateToPropsParam < TStateProps , TOwnProps , State > ,
343
- mapDispatchToProps : null | undefined ,
344
- mergeProps : MergeProps < TStateProps , undefined , TOwnProps , TMergedProps >
345
- ) : InferableComponentEnhancerWithProps < TMergedProps , TOwnProps & ConnectProps >
315
+ /** mapState and mapDispatch (as an object) */
316
+ < TStateProps = { } , TDispatchProps = { } , TOwnProps = { } , State = DefaultState > (
317
+ mapStateToProps : MapStateToPropsParam < TStateProps , TOwnProps , State > ,
318
+ mapDispatchToProps : MapDispatchToPropsParam < TDispatchProps , TOwnProps >
319
+ ) : InferableComponentEnhancerWithProps <
320
+ TStateProps & ResolveThunks < TDispatchProps > ,
321
+ TOwnProps
322
+ >
346
323
347
- /* @public */
348
- function connect <
349
- no_state = { } ,
350
- TDispatchProps = { } ,
351
- TOwnProps = { } ,
352
- TMergedProps = { }
353
- > (
354
- mapStateToProps : null | undefined ,
355
- mapDispatchToProps : MapDispatchToPropsParam < TDispatchProps , TOwnProps > ,
356
- mergeProps : MergeProps < undefined , TDispatchProps , TOwnProps , TMergedProps >
357
- ) : InferableComponentEnhancerWithProps < TMergedProps , TOwnProps & ConnectProps >
324
+ /** mergeProps only */
325
+ < no_state = { } , no_dispatch = { } , TOwnProps = { } , TMergedProps = { } > (
326
+ mapStateToProps : null | undefined ,
327
+ mapDispatchToProps : null | undefined ,
328
+ mergeProps : MergeProps < undefined , undefined , TOwnProps , TMergedProps >
329
+ ) : InferableComponentEnhancerWithProps < TMergedProps , TOwnProps >
330
+
331
+ /** mapState and mergeProps */
332
+ <
333
+ TStateProps = { } ,
334
+ no_dispatch = { } ,
335
+ TOwnProps = { } ,
336
+ TMergedProps = { } ,
337
+ State = DefaultState
338
+ > (
339
+ mapStateToProps : MapStateToPropsParam < TStateProps , TOwnProps , State > ,
340
+ mapDispatchToProps : null | undefined ,
341
+ mergeProps : MergeProps < TStateProps , undefined , TOwnProps , TMergedProps >
342
+ ) : InferableComponentEnhancerWithProps < TMergedProps , TOwnProps >
343
+
344
+ /** mapDispatch (as a object) and mergeProps */
345
+ < no_state = { } , TDispatchProps = { } , TOwnProps = { } , TMergedProps = { } > (
346
+ mapStateToProps : null | undefined ,
347
+ mapDispatchToProps : MapDispatchToPropsParam < TDispatchProps , TOwnProps > ,
348
+ mergeProps : MergeProps < undefined , TDispatchProps , TOwnProps , TMergedProps >
349
+ ) : InferableComponentEnhancerWithProps < TMergedProps , TOwnProps >
350
+
351
+ /** mapState and options */
352
+ < TStateProps = { } , no_dispatch = { } , TOwnProps = { } , State = DefaultState > (
353
+ mapStateToProps : MapStateToPropsParam < TStateProps , TOwnProps , State > ,
354
+ mapDispatchToProps : null | undefined ,
355
+ mergeProps : null | undefined ,
356
+ options : ConnectOptions < State , TStateProps , TOwnProps >
357
+ ) : InferableComponentEnhancerWithProps < DispatchProp & TStateProps , TOwnProps >
358
+
359
+ /** mapDispatch (as a function) and options */
360
+ < TStateProps = { } , TDispatchProps = { } , TOwnProps = { } > (
361
+ mapStateToProps : null | undefined ,
362
+ mapDispatchToProps : MapDispatchToPropsNonObject < TDispatchProps , TOwnProps > ,
363
+ mergeProps : null | undefined ,
364
+ options : ConnectOptions < { } , TStateProps , TOwnProps >
365
+ ) : InferableComponentEnhancerWithProps < TDispatchProps , TOwnProps >
366
+
367
+ /** mapDispatch (as an object) and options*/
368
+ < TStateProps = { } , TDispatchProps = { } , TOwnProps = { } > (
369
+ mapStateToProps : null | undefined ,
370
+ mapDispatchToProps : MapDispatchToPropsParam < TDispatchProps , TOwnProps > ,
371
+ mergeProps : null | undefined ,
372
+ options : ConnectOptions < { } , TStateProps , TOwnProps >
373
+ ) : InferableComponentEnhancerWithProps <
374
+ ResolveThunks < TDispatchProps > ,
375
+ TOwnProps
376
+ >
358
377
359
- /* @public */
360
- // @ts -ignore
361
- function connect <
362
- TStateProps = { } ,
363
- no_dispatch = { } ,
364
- TOwnProps = { } ,
365
- State = DefaultRootState
366
- > (
367
- mapStateToProps : MapStateToPropsParam < TStateProps , TOwnProps , State > ,
368
- mapDispatchToProps : null | undefined ,
369
- mergeProps : null | undefined ,
370
- options : ConnectOptions < State , TStateProps , TOwnProps >
371
- ) : InferableComponentEnhancerWithProps <
372
- DispatchProp & TStateProps ,
373
- TOwnProps & ConnectProps
374
- >
375
-
376
- /* @public */
377
- function connect < TStateProps = { } , TDispatchProps = { } , TOwnProps = { } > (
378
- mapStateToProps : null | undefined ,
379
- mapDispatchToProps : MapDispatchToPropsNonObject < TDispatchProps , TOwnProps > ,
380
- mergeProps : null | undefined ,
381
- options : ConnectOptions < { } , TStateProps , TOwnProps >
382
- ) : InferableComponentEnhancerWithProps < TDispatchProps , TOwnProps & ConnectProps >
383
-
384
- /* @public */
385
- function connect < TStateProps = { } , TDispatchProps = { } , TOwnProps = { } > (
386
- mapStateToProps : null | undefined ,
387
- mapDispatchToProps : MapDispatchToPropsParam < TDispatchProps , TOwnProps > ,
388
- mergeProps : null | undefined ,
389
- options : ConnectOptions < { } , TStateProps , TOwnProps >
390
- ) : InferableComponentEnhancerWithProps <
391
- ResolveThunks < TDispatchProps > ,
392
- TOwnProps & ConnectProps
393
- >
394
-
395
- /* @public */
396
- function connect <
397
- TStateProps = { } ,
398
- TDispatchProps = { } ,
399
- TOwnProps = { } ,
400
- State = DefaultRootState
401
- > (
402
- mapStateToProps : MapStateToPropsParam < TStateProps , TOwnProps , State > ,
403
- mapDispatchToProps : MapDispatchToPropsNonObject < TDispatchProps , TOwnProps > ,
404
- mergeProps : null | undefined ,
405
- options : ConnectOptions < State , TStateProps , TOwnProps >
406
- ) : InferableComponentEnhancerWithProps <
407
- TStateProps & TDispatchProps ,
408
- TOwnProps & ConnectProps
409
- >
410
-
411
- /* @public */
412
- function connect <
413
- TStateProps = { } ,
414
- TDispatchProps = { } ,
415
- TOwnProps = { } ,
416
- State = DefaultRootState
417
- > (
418
- mapStateToProps : MapStateToPropsParam < TStateProps , TOwnProps , State > ,
419
- mapDispatchToProps : MapDispatchToPropsParam < TDispatchProps , TOwnProps > ,
420
- mergeProps : null | undefined ,
421
- options : ConnectOptions < State , TStateProps , TOwnProps >
422
- ) : InferableComponentEnhancerWithProps <
423
- TStateProps & ResolveThunks < TDispatchProps > ,
424
- TOwnProps & ConnectProps
425
- >
426
-
427
- /* @public */
428
- function connect <
429
- TStateProps = { } ,
430
- TDispatchProps = { } ,
431
- TOwnProps = { } ,
432
- TMergedProps = { } ,
433
- State = DefaultRootState
434
- > (
435
- mapStateToProps ?: MapStateToPropsParam < TStateProps , TOwnProps , State > ,
436
- mapDispatchToProps ?: MapDispatchToPropsParam < TDispatchProps , TOwnProps > ,
437
- mergeProps ?: MergeProps < TStateProps , TDispatchProps , TOwnProps , TMergedProps > ,
438
- options ?: ConnectOptions < State , TStateProps , TOwnProps , TMergedProps >
439
- ) : InferableComponentEnhancerWithProps < TMergedProps , TOwnProps & ConnectProps >
378
+ /** mapState, mapDispatch (as a function), and options */
379
+ < TStateProps = { } , TDispatchProps = { } , TOwnProps = { } , State = DefaultState > (
380
+ mapStateToProps : MapStateToPropsParam < TStateProps , TOwnProps , State > ,
381
+ mapDispatchToProps : MapDispatchToPropsNonObject < TDispatchProps , TOwnProps > ,
382
+ mergeProps : null | undefined ,
383
+ options : ConnectOptions < State , TStateProps , TOwnProps >
384
+ ) : InferableComponentEnhancerWithProps <
385
+ TStateProps & TDispatchProps ,
386
+ TOwnProps
387
+ >
388
+
389
+ /** mapState, mapDispatch (as an object), and options */
390
+ < TStateProps = { } , TDispatchProps = { } , TOwnProps = { } , State = DefaultState > (
391
+ mapStateToProps : MapStateToPropsParam < TStateProps , TOwnProps , State > ,
392
+ mapDispatchToProps : MapDispatchToPropsParam < TDispatchProps , TOwnProps > ,
393
+ mergeProps : null | undefined ,
394
+ options : ConnectOptions < State , TStateProps , TOwnProps >
395
+ ) : InferableComponentEnhancerWithProps <
396
+ TStateProps & ResolveThunks < TDispatchProps > ,
397
+ TOwnProps
398
+ >
399
+
400
+ /** mapState, mapDispatch, mergeProps, and options */
401
+ <
402
+ TStateProps = { } ,
403
+ TDispatchProps = { } ,
404
+ TOwnProps = { } ,
405
+ TMergedProps = { } ,
406
+ State = DefaultState
407
+ > (
408
+ mapStateToProps : MapStateToPropsParam < TStateProps , TOwnProps , State > ,
409
+ mapDispatchToProps : MapDispatchToPropsParam < TDispatchProps , TOwnProps > ,
410
+ mergeProps : MergeProps <
411
+ TStateProps ,
412
+ TDispatchProps ,
413
+ TOwnProps ,
414
+ TMergedProps
415
+ > ,
416
+ options ?: ConnectOptions < State , TStateProps , TOwnProps , TMergedProps >
417
+ ) : InferableComponentEnhancerWithProps < TMergedProps , TOwnProps >
418
+ // tslint:enable:no-unnecessary-generics
419
+ }
440
420
441
421
/**
442
422
* Connects a React component to a Redux store.
@@ -826,4 +806,4 @@ function connect<
826
806
return wrapWithConnect
827
807
}
828
808
829
- export default connect
809
+ export default connect as Connect
0 commit comments