@@ -7,10 +7,11 @@ import React, {
7
7
useState ,
8
8
useContext ,
9
9
} from 'react'
10
- import { createStore } from 'redux'
10
+ import { Action , createStore } from 'redux'
11
11
import * as rtl from '@testing-library/react'
12
12
import {
13
- Provider as ProviderMock ,
13
+ Provider ,
14
+ ProviderProps ,
14
15
useSelector ,
15
16
useDispatch ,
16
17
shallowEqual ,
@@ -26,6 +27,15 @@ import type {
26
27
import type { FunctionComponent , DispatchWithoutAction , ReactNode } from 'react'
27
28
import type { Store , AnyAction } from 'redux'
28
29
30
+ // most of these tests depend on selectors being run once, which stabilityCheck doesn't do
31
+ // rather than specify it every time, let's make a new "default" here
32
+ function ProviderMock < A extends Action < any > = AnyAction , S = unknown > ( {
33
+ stabilityCheck = 'never' ,
34
+ ...props
35
+ } : ProviderProps < A , S > ) {
36
+ return < Provider { ...props } stabilityCheck = { stabilityCheck } />
37
+ }
38
+
29
39
const IS_REACT_18 = React . version . startsWith ( '18' )
30
40
31
41
describe ( 'React' , ( ) => {
@@ -349,7 +359,7 @@ describe('React', () => {
349
359
numCalls += 1
350
360
return s . count
351
361
}
352
- const renderedItems = [ ]
362
+ const renderedItems : number [ ] = [ ]
353
363
354
364
const Comp = ( ) => {
355
365
const value = useSelector ( selector )
@@ -387,7 +397,7 @@ describe('React', () => {
387
397
numCalls += 1
388
398
return s . count
389
399
}
390
- const renderedItems = [ ]
400
+ const renderedItems : number [ ] = [ ]
391
401
392
402
const Child = ( ) => {
393
403
useLayoutEffect ( ( ) => {
@@ -746,21 +756,21 @@ describe('React', () => {
746
756
null as any
747
757
)
748
758
const useCustomSelector = createSelectorHook ( nestedContext )
749
- let defaultCount = null
750
- let customCount = null
759
+ let defaultCount : number | null = null
760
+ let customCount : number | null = null
751
761
752
762
const getCount = ( s : StateType ) => s . count
753
763
754
764
const DisplayDefaultCount = ( { children = null } ) => {
755
- const count = useSelector < StateType > ( getCount )
765
+ const count = useSelector ( getCount )
756
766
defaultCount = count
757
767
return < > { children } </ >
758
768
}
759
769
interface DisplayCustomCountType {
760
770
children : ReactNode
761
771
}
762
772
const DisplayCustomCount = ( { children } : DisplayCustomCountType ) => {
763
- const count = useCustomSelector < StateType > ( getCount )
773
+ const count = useCustomSelector ( getCount )
764
774
customCount = count
765
775
return < > { children } </ >
766
776
}
0 commit comments