Skip to content

Commit fe29b74

Browse files
authored
fix: delete legacy type problems (#1812)
1 parent f278933 commit fe29b74

File tree

2 files changed

+40
-28
lines changed

2 files changed

+40
-28
lines changed

src/components/connect.tsx

+32-14
Original file line numberDiff line numberDiff line change
@@ -280,19 +280,25 @@ function connect<
280280
State = DefaultRootState
281281
>(
282282
mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>
283-
): InferableComponentEnhancerWithProps<TStateProps & DispatchProp, TOwnProps>
283+
): InferableComponentEnhancerWithProps<
284+
TStateProps & DispatchProp,
285+
TOwnProps & ConnectProps
286+
>
284287

285288
/* @public */
286289
function connect<no_state = {}, TDispatchProps = {}, TOwnProps = {}>(
287290
mapStateToProps: null | undefined,
288291
mapDispatchToProps: MapDispatchToPropsNonObject<TDispatchProps, TOwnProps>
289-
): InferableComponentEnhancerWithProps<TDispatchProps, TOwnProps>
292+
): InferableComponentEnhancerWithProps<TDispatchProps, TOwnProps & ConnectProps>
290293

291294
/* @public */
292295
function connect<no_state = {}, TDispatchProps = {}, TOwnProps = {}>(
293296
mapStateToProps: null | undefined,
294297
mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>
295-
): InferableComponentEnhancerWithProps<ResolveThunks<TDispatchProps>, TOwnProps>
298+
): InferableComponentEnhancerWithProps<
299+
ResolveThunks<TDispatchProps>,
300+
TOwnProps & ConnectProps
301+
>
296302

297303
/* @public */
298304
function connect<
@@ -303,7 +309,10 @@ function connect<
303309
>(
304310
mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>,
305311
mapDispatchToProps: MapDispatchToPropsNonObject<TDispatchProps, TOwnProps>
306-
): InferableComponentEnhancerWithProps<TStateProps & TDispatchProps, TOwnProps>
312+
): InferableComponentEnhancerWithProps<
313+
TStateProps & TDispatchProps,
314+
TOwnProps & ConnectProps
315+
>
307316

308317
/* @public */
309318
function connect<
@@ -316,7 +325,7 @@ function connect<
316325
mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>
317326
): InferableComponentEnhancerWithProps<
318327
TStateProps & ResolveThunks<TDispatchProps>,
319-
TOwnProps
328+
TOwnProps & ConnectProps
320329
>
321330

322331
/* @public */
@@ -329,7 +338,7 @@ function connect<
329338
mapStateToProps: null | undefined,
330339
mapDispatchToProps: null | undefined,
331340
mergeProps: MergeProps<undefined, undefined, TOwnProps, TMergedProps>
332-
): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps>
341+
): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps & ConnectProps>
333342

334343
/* @public */
335344
function connect<
@@ -342,7 +351,7 @@ function connect<
342351
mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>,
343352
mapDispatchToProps: null | undefined,
344353
mergeProps: MergeProps<TStateProps, undefined, TOwnProps, TMergedProps>
345-
): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps>
354+
): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps & ConnectProps>
346355

347356
/* @public */
348357
function connect<
@@ -354,7 +363,7 @@ function connect<
354363
mapStateToProps: null | undefined,
355364
mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>,
356365
mergeProps: MergeProps<undefined, TDispatchProps, TOwnProps, TMergedProps>
357-
): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps>
366+
): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps & ConnectProps>
358367

359368
/* @public */
360369
// @ts-ignore
@@ -368,23 +377,29 @@ function connect<
368377
mapDispatchToProps: null | undefined,
369378
mergeProps: null | undefined,
370379
options: ConnectOptions<State, TStateProps, TOwnProps>
371-
): InferableComponentEnhancerWithProps<DispatchProp & TStateProps, TOwnProps>
380+
): InferableComponentEnhancerWithProps<
381+
DispatchProp & TStateProps,
382+
TOwnProps & ConnectProps
383+
>
372384

373385
/* @public */
374386
function connect<TStateProps = {}, TDispatchProps = {}, TOwnProps = {}>(
375387
mapStateToProps: null | undefined,
376388
mapDispatchToProps: MapDispatchToPropsNonObject<TDispatchProps, TOwnProps>,
377389
mergeProps: null | undefined,
378390
options: ConnectOptions<{}, TStateProps, TOwnProps>
379-
): InferableComponentEnhancerWithProps<TDispatchProps, TOwnProps>
391+
): InferableComponentEnhancerWithProps<TDispatchProps, TOwnProps & ConnectProps>
380392

381393
/* @public */
382394
function connect<TStateProps = {}, TDispatchProps = {}, TOwnProps = {}>(
383395
mapStateToProps: null | undefined,
384396
mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>,
385397
mergeProps: null | undefined,
386398
options: ConnectOptions<{}, TStateProps, TOwnProps>
387-
): InferableComponentEnhancerWithProps<ResolveThunks<TDispatchProps>, TOwnProps>
399+
): InferableComponentEnhancerWithProps<
400+
ResolveThunks<TDispatchProps>,
401+
TOwnProps & ConnectProps
402+
>
388403

389404
/* @public */
390405
function connect<
@@ -397,7 +412,10 @@ function connect<
397412
mapDispatchToProps: MapDispatchToPropsNonObject<TDispatchProps, TOwnProps>,
398413
mergeProps: null | undefined,
399414
options: ConnectOptions<State, TStateProps, TOwnProps>
400-
): InferableComponentEnhancerWithProps<TStateProps & TDispatchProps, TOwnProps>
415+
): InferableComponentEnhancerWithProps<
416+
TStateProps & TDispatchProps,
417+
TOwnProps & ConnectProps
418+
>
401419

402420
/* @public */
403421
function connect<
@@ -412,7 +430,7 @@ function connect<
412430
options: ConnectOptions<State, TStateProps, TOwnProps>
413431
): InferableComponentEnhancerWithProps<
414432
TStateProps & ResolveThunks<TDispatchProps>,
415-
TOwnProps
433+
TOwnProps & ConnectProps
416434
>
417435

418436
/* @public */
@@ -427,7 +445,7 @@ function connect<
427445
mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>,
428446
mergeProps: MergeProps<TStateProps, TDispatchProps, TOwnProps, TMergedProps>,
429447
options?: ConnectOptions<State, TStateProps, TOwnProps, TMergedProps>
430-
): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps>
448+
): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps & ConnectProps>
431449

432450
/**
433451
* Connects a React component to a Redux store.

test/components/connect.spec.tsx

+8-14
Original file line numberDiff line numberDiff line change
@@ -2179,10 +2179,6 @@ describe('React', () => {
21792179
rtl.render(
21802180
<ProviderMock context={context} store={store1}>
21812181
<ProviderMock store={store2}>
2182-
{/*TODO: Since the connect type does not support this advanced usage,
2183-
we will ignore it for the time being and resolve it after merging connect and connectAdvanced
2184-
https://github.com/reduxjs/react-redux/pull/1781 */}
2185-
{/*// @ts-ignore */}
21862182
<Decorated context={context} />
21872183
</ProviderMock>
21882184
</ProviderMock>
@@ -2211,13 +2207,9 @@ describe('React', () => {
22112207
const Decorated = decorator(Container)
22122208

22132209
const store = createStore(() => expectedState)
2214-
22152210
rtl.render(
22162211
<ProviderMock store={store}>
2217-
{/*TODO: Since the connect type does not support this advanced usage,
2218-
we will ignore it for the time being and resolve it after merging connect and connectAdvanced
2219-
https://github.com/reduxjs/react-redux/pull/1781 */}
2220-
{/*// @ts-ignore */}
2212+
{/*@ts-expect-error*/}
22212213
<Decorated context={nonContext} />
22222214
</ProviderMock>
22232215
)
@@ -2259,6 +2251,7 @@ describe('React', () => {
22592251

22602252
const rendered = rtl.render(
22612253
<ProviderMock store={store}>
2254+
{/*@ts-expect-error*/}
22622255
<Decorated store={notActuallyAStore} />
22632256
</ProviderMock>
22642257
)
@@ -2307,7 +2300,6 @@ describe('React', () => {
23072300
</div>
23082301
)
23092302
}
2310-
const ConnectedComp2 = connect((state) => state)(Comp2)
23112303

23122304
type Comp1TStatePropsType = Store1State1Type
23132305
type Comp1NoDispatchType = NoDispatchType
@@ -2354,17 +2346,19 @@ describe('React', () => {
23542346
return state
23552347
}
23562348
}
2349+
const ConnectedComp2 = connect<
2350+
Store2State1Type,
2351+
unknown,
2352+
unknown,
2353+
Store2State1Type
2354+
>((state) => state)(Comp2)
23572355

23582356
const store1 = createStore(reducer1)
23592357
const store2 = createStore(reducer2)
23602358

23612359
const tester = rtl.render(
23622360
<ProviderMock store={store1}>
23632361
<ConnectedComp1>
2364-
{/*TODO: Since the connect type does not support this advanced usage,
2365-
we will ignore it for the time being and resolve it after merging connect and connectAdvanced
2366-
https://github.com/reduxjs/react-redux/pull/1781 */}
2367-
{/*// @ts-ignore */}
23682362
<ConnectedComp2 store={store2} />
23692363
</ConnectedComp1>
23702364
</ProviderMock>

0 commit comments

Comments
 (0)