diff --git a/packages/query-core/src/queriesObserver.ts b/packages/query-core/src/queriesObserver.ts index 8bfb33e954..b00be002c8 100644 --- a/packages/query-core/src/queriesObserver.ts +++ b/packages/query-core/src/queriesObserver.ts @@ -45,7 +45,7 @@ export class QueriesObserver< constructor( client: QueryClient, - queries: Array, + queries: Array>, _options?: QueriesObserverOptions, ) { super() diff --git a/packages/react-query/src/__tests__/queryOptions.test-d.tsx b/packages/react-query/src/__tests__/queryOptions.test-d.tsx index dcb8d0ca47..f7189e567d 100644 --- a/packages/react-query/src/__tests__/queryOptions.test-d.tsx +++ b/packages/react-query/src/__tests__/queryOptions.test-d.tsx @@ -1,9 +1,10 @@ import { describe, expect, expectTypeOf, it } from 'vitest' -import { QueryClient, dataTagSymbol, skipToken } from '@tanstack/query-core' +import { QueriesObserver, QueryClient, dataTagSymbol, skipToken } from '@tanstack/query-core' import { queryOptions } from '../queryOptions' import { useQuery } from '../useQuery' import { useQueries } from '../useQueries' import { useSuspenseQuery } from '../useSuspenseQuery' +import type { QueryObserverResult } from '@tanstack/query-core'; describe('queryOptions', () => { it('should not allow excess properties', () => { @@ -169,4 +170,15 @@ describe('queryOptions', () => { const data = queryClient.getQueryData(options.queryKey) expectTypeOf(data).toEqualTypeOf() }) + + it('should return the proper type when passed to QueriesObserver', () => { + const options = queryOptions({ + queryKey: ['key'], + queryFn: () => Promise.resolve(5), + }) + + const queryClient = new QueryClient() + const queriesObserver = new QueriesObserver(queryClient, [options]) + expectTypeOf(queriesObserver).toEqualTypeOf>>() + }) })