@@ -35,8 +35,6 @@ describe('union types', () => {
3535 }
3636
3737 if ( result . isLoading ) {
38- expectTypeOf ( result . data ) . toBeNullable ( )
39-
4038 expectTypeOf ( result . data ) . toEqualTypeOf < string | undefined > ( )
4139
4240 expectTypeOf ( result . error ) . toEqualTypeOf <
@@ -88,6 +86,7 @@ describe('union types', () => {
8886 expectTypeOf ( result ) . toBeNever ( )
8987 }
9088 } )
89+
9190 test ( 'useQuery union' , ( ) => {
9291 const result = api . endpoints . getTest . useQuery ( )
9392
@@ -136,6 +135,7 @@ describe('union types', () => {
136135
137136 expectTypeOf ( result . isFetching ) . toEqualTypeOf < false > ( )
138137 }
138+
139139 if ( result . isSuccess ) {
140140 expectTypeOf ( result . data ) . toBeString ( )
141141
@@ -168,15 +168,11 @@ describe('union types', () => {
168168
169169 expectTypeOf ( result . currentData ) . toEqualTypeOf < string | undefined > ( )
170170
171- expectTypeOf ( result . currentData ) . not . toBeString ( )
172-
173171 if ( result . isSuccess ) {
174172 if ( ! result . isFetching ) {
175173 expectTypeOf ( result . currentData ) . toBeString ( )
176174 } else {
177175 expectTypeOf ( result . currentData ) . toEqualTypeOf < string | undefined > ( )
178-
179- expectTypeOf ( result . currentData ) . not . toBeString ( )
180176 }
181177 }
182178
@@ -300,6 +296,7 @@ describe('union types', () => {
300296
301297 expectTypeOf ( result . isFetching ) . toEqualTypeOf < false > ( )
302298 }
299+
303300 if ( result . isLoading ) {
304301 expectTypeOf ( result . data ) . toBeUndefined ( )
305302
@@ -469,37 +466,32 @@ describe('union types', () => {
469466
470467 test ( 'queryHookResult (without selector) union' , async ( ) => {
471468 const useQueryStateResult = api . endpoints . getTest . useQueryState ( )
469+
472470 const useQueryResult = api . endpoints . getTest . useQuery ( )
473- const useQueryStateWithSelectFromResult = api . endpoints . getTest . useQueryState (
474- undefined ,
475- {
471+
472+ const useQueryStateWithSelectFromResult =
473+ api . endpoints . getTest . useQueryState ( undefined , {
476474 selectFromResult : ( ) => ( { x : true } ) ,
477- }
478- )
475+ } )
479476
480477 const { refetch, ...useQueryResultWithoutMethods } = useQueryResult
481478
482479 assertType < typeof useQueryResultWithoutMethods > ( useQueryStateResult )
483480
484481 expectTypeOf ( useQueryStateResult ) . toMatchTypeOf (
485- useQueryResultWithoutMethods
486- )
487-
488- expectTypeOf ( useQueryStateResult ) . not . toEqualTypeOf (
489- useQueryResultWithoutMethods
482+ useQueryResultWithoutMethods ,
490483 )
491484
492485 expectTypeOf ( useQueryStateWithSelectFromResult )
493486 . parameter ( 0 )
494- . not . toEqualTypeOf ( useQueryResultWithoutMethods )
487+ . not . toMatchTypeOf ( useQueryResultWithoutMethods )
495488
496489 expectTypeOf ( api . endpoints . getTest . select ) . returns . returns . toEqualTypeOf <
497490 Awaited < ReturnType < typeof refetch > >
498491 > ( )
499492 } )
500493
501494 test ( 'useQueryState (with selectFromResult)' , ( ) => {
502-
503495 const result = api . endpoints . getTest . useQueryState ( undefined , {
504496 selectFromResult ( {
505497 data,
@@ -782,12 +774,5 @@ describe('"Typed" helper types', () => {
782774 expectTypeOf <
783775 TypedUseMutationResult < string , void , typeof baseQuery >
784776 > ( ) . toMatchTypeOf ( result )
785-
786- // TODO: `TypedUseMutationResult` might need a closer look since here the result is assignable to it but they are not of equal types
787- expectTypeOf <
788- TypedUseMutationResult < string , void , typeof baseQuery >
789- > ( ) . not . toEqualTypeOf ( result )
790-
791- assertType < TypedUseMutationResult < string , void , typeof baseQuery > > ( result )
792777 } )
793778} )
0 commit comments