Skip to content

Commit 7fe1333

Browse files
authored
fix(query): ensure PageParam is typed without select (#153)
Also update tests for infiniteOptions with initialParams is undefined
1 parent 3cb80cf commit 7fe1333

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

packages/react-query/src/procedure-utils.test-d.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Client } from '@orpc/client'
22
import type { ErrorFromErrorMap } from '@orpc/contract'
3-
import type { InfiniteData } from '@tanstack/react-query'
3+
import type { GetNextPageParamFunction, InfiniteData } from '@tanstack/react-query'
44
import type { baseErrorMap } from '../../contract/tests/shared'
55
import type { ProcedureUtils } from './procedure-utils'
66
import { useInfiniteQuery, useMutation, useQueries, useQuery, useSuspenseInfiniteQuery, useSuspenseQuery } from '@tanstack/react-query'
@@ -119,7 +119,7 @@ describe('ProcedureUtils', () => {
119119
})
120120

121121
describe('.infiniteOptions', () => {
122-
const getNextPageParam = {} as () => number
122+
const getNextPageParam = {} as GetNextPageParamFunction<number, UtilsOutput>
123123
const initialPageParam = 1
124124

125125
it('can optional context', () => {
@@ -157,11 +157,10 @@ describe('ProcedureUtils', () => {
157157
})
158158

159159
utils.infiniteOptions({
160-
input: (pageParam) => {
161-
expectTypeOf(pageParam).toEqualTypeOf<number | undefined>()
160+
input: (pageParam: number | undefined) => {
162161
return { cursor: pageParam }
163162
},
164-
getNextPageParam,
163+
getNextPageParam: lastPage => 1,
165164
initialPageParam: undefined,
166165
})
167166

packages/react-query/src/procedure-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export interface ProcedureUtils<TClientContext extends ClientContext, TInput, TO
1313
>
1414
): NoInfer<U & QueryOptionsBase<TOutput, TError>>
1515

16-
infiniteOptions<U, UPageParam, USelectData = InfiniteData<TOutput>>(
16+
infiniteOptions<U, UPageParam, USelectData = InfiniteData<TOutput, UPageParam>>(
1717
options: U & InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, USelectData, UPageParam>
1818
): NoInfer<U & InfiniteOptionsBase<TOutput, TError, UPageParam>>
1919

packages/vue-query/src/procedure-utils.test-d.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Client } from '@orpc/client'
22
import type { ErrorFromErrorMap } from '@orpc/contract'
3-
import type { InfiniteData } from '@tanstack/vue-query'
3+
import type { GetNextPageParamFunction, InfiniteData } from '@tanstack/vue-query'
44
import type { baseErrorMap } from '../../contract/tests/shared'
55
import type { ProcedureUtils } from './procedure-utils'
66
import { useInfiniteQuery, useMutation, useQueries, useQuery } from '@tanstack/vue-query'
@@ -113,7 +113,7 @@ describe('ProcedureUtils', () => {
113113
})
114114

115115
describe('.infiniteOptions', () => {
116-
const getNextPageParam = {} as () => number
116+
const getNextPageParam = {} as GetNextPageParamFunction<number, UtilsOutput>
117117
const initialPageParam = 1
118118

119119
it('can optional context', () => {
@@ -151,11 +151,10 @@ describe('ProcedureUtils', () => {
151151
})
152152

153153
utils.infiniteOptions({
154-
input: (pageParam) => {
155-
expectTypeOf(pageParam).toEqualTypeOf<number | undefined>()
154+
input: (pageParam: number | undefined) => {
156155
return { cursor: pageParam }
157156
},
158-
getNextPageParam,
157+
getNextPageParam: lastPage => 1,
159158
initialPageParam: undefined,
160159
})
161160

packages/vue-query/src/procedure-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface ProcedureUtils<TClientContext extends ClientContext, TInput, TO
1515
>
1616
): NoInfer<U & QueryOptionsBase<TOutput, TError>>
1717

18-
infiniteOptions<U, UPageParam, USelectData = InfiniteData<TOutput>>(
18+
infiniteOptions<U, UPageParam, USelectData = InfiniteData<TOutput, UPageParam>>(
1919
options: U & InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, USelectData, UPageParam>
2020
): NoInfer<U & InfiniteOptionsBase<TOutput, TError, UPageParam>>
2121

0 commit comments

Comments
 (0)