File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ import {
3434 fetchCount ,
3535} from './counterApp'
3636
37- import { expectType } from '../typeTestHelpers'
37+ import { expectType , expectExactType } from '../typeTestHelpers'
3838
3939function preTypedHooksSetup ( ) {
4040 // Standard hooks setup
@@ -87,6 +87,20 @@ function testShallowEqual() {
8787 shallowEqual ( { test : 'test' } , { test : 'test' } )
8888 shallowEqual ( { test : 'test' } , 'a' )
8989 const x : boolean = shallowEqual ( 'a' , 'a' )
90+
91+ type TestState = { stateProp : string }
92+
93+ // Additionally, it should infer its type from arguments and not become `any`
94+ const selected1 = useSelector (
95+ ( state : TestState ) => state . stateProp ,
96+ shallowEqual
97+ )
98+ expectExactType < string > ( selected1 )
99+
100+ const useAppSelector : TypedUseSelectorHook < TestState > = useSelector
101+
102+ const selected2 = useAppSelector ( ( state ) => state . stateProp , shallowEqual )
103+ expectExactType < string > ( selected2 )
90104}
91105
92106function testUseDispatch ( ) {
You can’t perform that action at this time.
0 commit comments