Skip to content

Commit a87698b

Browse files
committed
fix(types): resolve UseInfiniteQueryMethod type mismatch with infiniteQueryOptions
- Add initialPageParam to UseInfiniteQueryMethod options - Use InferPageParamType<Options> instead of unknown for TPageParam - Clean up unused variables in tests
1 parent 07aea3a commit a87698b

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

packages/openapi-react-query/biome.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"root": false,
3-
"$schema": "https://biomejs.dev/schemas/2.2.4/schema.json",
3+
"$schema": "https://biomejs.dev/schemas/2.2.5/schema.json",
44
"extends": "//",
55
"files": {
6-
"includes": ["**", "!dist/**", "!test/fixtures/**"]
6+
"includes": ["**", "!dist", "!test/fixtures"]
77
},
88
"linter": {
99
"rules": {

packages/openapi-react-query/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,12 @@ export type UseInfiniteQueryMethod<Paths extends Record<string, Record<HttpMetho
165165
Response["error"],
166166
InferSelectReturnType<InfiniteData<Response["data"]>, Options["select"]>,
167167
QueryKey<Paths, Method, Path>,
168-
unknown
168+
InferPageParamType<Options>
169169
>,
170170
"queryKey" | "queryFn"
171171
> & {
172172
pageParamName?: string;
173+
initialPageParam: InferPageParamType<Options>;
173174
},
174175
>(
175176
method: Method,

packages/openapi-react-query/test/index.test.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ describe("client", () => {
8787
const fetchClient = createFetchClient<paths>({ baseUrl });
8888
const client = createClient(fetchClient);
8989

90-
if (!("infiniteQueryOptions" in client)) return;
91-
9290
const options = client.infiniteQueryOptions(
9391
"get",
9492
"/paginated-data",
@@ -128,8 +126,6 @@ describe("client", () => {
128126
const fetchClient = createFetchClient<paths>({ baseUrl });
129127
const client = createClient(fetchClient);
130128

131-
if (!("infiniteQueryOptions" in client)) return;
132-
133129
const options = client.infiniteQueryOptions(
134130
"get",
135131
"/paginated-data",
@@ -1106,7 +1102,7 @@ describe("client", () => {
11061102
expect(firstRequestUrl?.searchParams.get("cursor")).toBe("0");
11071103

11081104
// Set up mock for second page before triggering next page fetch
1109-
const secondRequestHandler = useMockRequestHandler({
1105+
useMockRequestHandler({
11101106
baseUrl,
11111107
method: "get",
11121108
path: "/paginated-data",
@@ -1233,7 +1229,7 @@ describe("client", () => {
12331229
const client = createClient(fetchClient);
12341230

12351231
// First page request handler
1236-
const firstRequestHandler = useMockRequestHandler({
1232+
useMockRequestHandler({
12371233
baseUrl,
12381234
method: "get",
12391235
path: "/paginated-data",
@@ -1269,7 +1265,7 @@ describe("client", () => {
12691265
expect(result.current.data).toEqual([1, 2, 3]);
12701266

12711267
// Set up mock for second page before triggering next page fetch
1272-
const secondRequestHandler = useMockRequestHandler({
1268+
useMockRequestHandler({
12731269
baseUrl,
12741270
method: "get",
12751271
path: "/paginated-data",

0 commit comments

Comments
 (0)