Skip to content
Source
Sign inSign up
TanStack/query

fix(types): make sure queryOptions are passable to UseQueryOptions #8317

MergedTkDodomerged 1 commit intomain fromrefs/pull/8317/headmerged by TkDodo View on GitHub

Showing 2 changed files with 18 additions and 4 deletions.

x
0 of 2 viewed, 2 left
14 additions and 0 deletionspackages/react-query/src/__tests__/queryOptions.test-d.tsxModified
View file
@@ -9,6 +9,7 @@
import { useQuery } from '../useQuery'
import { useQueries } from '../useQueries'
import { useSuspenseQuery } from '../useSuspenseQuery'
+import type { UseQueryOptions } from '../types'
import type {
InitialDataFunction,
QueryObserverResult,
@@ -233,4 +234,17 @@
testFn('id')
testFn()
+​
+ it('should be passable to UseQueryOptions', () => {
+ function somethingWithQueryOptions(options: UseQueryOptions<number>) {
+ return options.queryKey
+ }
+​
+ const options = queryOptions({
+ queryKey: ['key'],
+ queryFn: () => Promise.resolve(1),
+ })
+​
+ somethingWithQueryOptions(options)
+ })