Skip to content

Commit de2aa1d

Browse files
committed
Add type tests for TypedUseQueryStateOptions
1 parent 93bb369 commit de2aa1d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

packages/toolkit/src/query/tests/unionTypes.test-d.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import type { UseQueryStateOptions } from '@internal/query/react/buildHooks'
12
import type { SerializedError } from '@reduxjs/toolkit'
23
import type {
34
FetchBaseQueryError,
5+
QueryDefinition,
46
TypedUseMutationResult,
57
TypedUseQueryHookResult,
68
TypedUseQueryState,
@@ -13,6 +15,7 @@ import type {
1315
TypedMutationTrigger,
1416
TypedUseQuerySubscription,
1517
TypedUseQuery,
18+
TypedUseQueryStateOptions,
1619
} from '@reduxjs/toolkit/query/react'
1720
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'
1821

@@ -776,6 +779,23 @@ describe('"Typed" helper types', () => {
776779
>().toEqualTypeOf(result)
777780
})
778781

782+
test('useQueryState options', () => {
783+
expectTypeOf<
784+
TypedUseQueryStateOptions<string, void, typeof baseQuery>
785+
>().toMatchTypeOf<
786+
Parameters<typeof api.endpoints.getTest.useQueryState>[1]
787+
>()
788+
789+
expectTypeOf<
790+
UseQueryStateOptions<
791+
QueryDefinition<void, typeof baseQuery, string, string>,
792+
{ x: boolean }
793+
>
794+
>().toEqualTypeOf<
795+
TypedUseQueryStateOptions<string, void, typeof baseQuery, { x: boolean }>
796+
>()
797+
})
798+
779799
test('useQuerySubscription', () => {
780800
expectTypeOf<
781801
TypedUseQuerySubscription<string, void, typeof baseQuery>

0 commit comments

Comments
 (0)