Description
The generated InfiniteOptions aren't compatible with useSuspenseInfiniteQuery.
I get the typescript error:
Argument of type '{ subscribed?: boolean; throwOnError?: ThrowOnError<CatsPage, Error, InfiniteData<CatsPage, number | Pick<Pick<Options<GetCatsData>, "body" | "path" | "query" | "headers" | "baseUrl"> & { ...; }, "body" | ... 2 more ... | "headers">>, QueryKey<...>> | undefined; ... 31 more ...; initialPageParam: number | Pick<...>; }' is not assignable to parameter of type 'UseSuspenseInfiniteQueryOptions<CatsPage, Error, InfiniteData<CatsPage, unknown>, QueryKey<Options<GetCatsData>>, number | Pick<Pick<...> & { ...; }, "body" | ... 2 more ... | "headers">>'.
Types of property 'queryFn' are incompatible.
Type 'unique symbol | QueryFunction<CatsPage, QueryKey<Options<GetCatsData>>, number | Pick<Pick<Options<GetCatsData>, "body" | ... 3 more ... | "baseUrl"> & { ...; }, "body" | ... 2 more ... | "headers">> | undefined' is not assignable to type 'QueryFunction<CatsPage, QueryKey<Options<GetCatsData>>, number | Pick<Pick<Options<GetCatsData>, "body" | "path" | "query" | "headers" | "baseUrl"> & { ...; }, "body" | ... 2 more ... | "headers">> | undefined'.
Type 'typeof skipToken' is not assignable to type 'QueryFunction<CatsPage, QueryKey<Options<GetCatsData>>, number | Pick<Pick<Options<GetCatsData>, "body" | "path" | "query" | "headers" | "baseUrl"> & { ...; }, "body" | ... 2 more ... | "headers">>'.ts(2345)
Reproducible example or configuration
openapi-ts.config.ts
import { defineConfig } from "@hey-api/openapi-ts";
export default defineConfig({
input: "openapi.json",
output: "src/openapi",
plugins: [
{
name: "@tanstack/react-query",
infiniteQueryOptions: true
},
{
name: "@hey-api/typescript",
enums: "typescript"
}
]
});
test.ts
const result = useSuspenseInfiniteQuery({
...getCatsInfiniteOptions({
query: {
page: 0,
pageSize: 100
}
})
});
OpenAPI specification (optional)
{
"openapi": "3.0.4",
"info": {
"title": "pets",
"version": "1.0.0"
},
"paths": {
"/api/pets": {
"get": {
"operationId": "getCats",
"parameters": [
{
"name": "page",
"in": "query",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
},
{
"name": "pageSize",
"in": "query",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CatsPage"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"CatsPage": {
"type": "object",
"required": [
"hasNextPage",
"hasPreviousPage",
"items",
"page",
"pageSize",
"totalCount",
"totalPages"
],
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Cat"
}
},
"page": {
"type": "integer",
"format": "int32"
},
"pageSize": {
"type": "integer",
"format": "int32"
},
"totalCount": {
"type": "integer",
"format": "int32"
},
"totalPages": {
"type": "integer",
"format": "int32"
},
"hasPreviousPage": {
"type": "boolean"
},
"previousPage": {
"type": "integer",
"format": "int32"
},
"hasNextPage": {
"type": "boolean"
},
"nextPage": {
"type": "integer",
"format": "int32"
}
}
},
"Cat": {
"type": "object",
"properties": {
"whiskerLength": {
"type": "integer"
}
}
}
}
}
}
System information (optional)
@hey-api/openapi-ts: 0.86.11
@tanstack/react-query: 5.90.6
Node: v24.10.0
Npm: 11.6.1
Typescript: 5.9.2
Windows: 11 24H2 26100.6899
Description
The generated
InfiniteOptionsaren't compatible withuseSuspenseInfiniteQuery.I get the typescript error:
Reproducible example or configuration
openapi-ts.config.ts
test.ts
OpenAPI specification (optional)
{ "openapi": "3.0.4", "info": { "title": "pets", "version": "1.0.0" }, "paths": { "/api/pets": { "get": { "operationId": "getCats", "parameters": [ { "name": "page", "in": "query", "required": true, "schema": { "type": "integer", "format": "int32" } }, { "name": "pageSize", "in": "query", "required": true, "schema": { "type": "integer", "format": "int32" } } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CatsPage" } } } } } } } }, "components": { "schemas": { "CatsPage": { "type": "object", "required": [ "hasNextPage", "hasPreviousPage", "items", "page", "pageSize", "totalCount", "totalPages" ], "properties": { "items": { "type": "array", "items": { "$ref": "#/components/schemas/Cat" } }, "page": { "type": "integer", "format": "int32" }, "pageSize": { "type": "integer", "format": "int32" }, "totalCount": { "type": "integer", "format": "int32" }, "totalPages": { "type": "integer", "format": "int32" }, "hasPreviousPage": { "type": "boolean" }, "previousPage": { "type": "integer", "format": "int32" }, "hasNextPage": { "type": "boolean" }, "nextPage": { "type": "integer", "format": "int32" } } }, "Cat": { "type": "object", "properties": { "whiskerLength": { "type": "integer" } } } } } }System information (optional)
@hey-api/openapi-ts: 0.86.11
@tanstack/react-query: 5.90.6
Node: v24.10.0
Npm: 11.6.1
Typescript: 5.9.2
Windows: 11 24H2 26100.6899