We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When generating an orval client with v7.4.0 using TanStack Query and fetch, orval emits an invalid return type for the response data.
const { data } = useGetUsers( { limit, offset }, { request: { accessKey }, query: { placeholderData: keepPreviousData } }, );
In v7.3.0, the return type was User[] | undefined, but with v7.4.0 it emits the following type error.
User[] | undefined
Type '<T>(previousData: T | undefined) => T | undefined' is not assignable to type 'unknown[]'.
The orval config is
import { defineConfig } from "orval"; export default defineConfig({ exchange: { input: { target: "openapi.yml", }, output: { client: "react-query", mode: "tags-split", baseUrl: process.env.BASE_URL, workspace: "src/lib/api", target: "index.ts", schemas: "models", prettier: true, clean: true, override: { query: { useSuspenseQuery: true, }, mutator: { path: "../custom-client.ts", name: "customRequest", }, useTypeOverInterfaces: true, }, }, hooks: { afterAllFilesWrite: "prettier -w src/lib/api/**/*.ts", }, }, });
and the custom client is
export const customRequest = async <T>( config: { url: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; params?: Record<string, unknown>; headers?: Record<string, unknown>; data?: unknown; responseType?: string; signal?: AbortSignal; }, options?: { accessKey: string | undefined }, ): Promise<T> => { const params = parseParams(config.params); const res = await fetch(config.url + params, { ...config, ...options, body: JSON.stringify(config.data), headers: { ...config.headers, ...(options?.accessKey != null ? { Authorization: `Bearer ${options.accessKey}`, } : []), }, }); return await res.json(); };
System: OS: macOS 15.2 CPU: (12) arm64 Apple M3 Pro Memory: 3.34 GB / 36.00 GB Shell: 5.9 - /bin/zsh npmPackages: @tanstack/react-query: ^5.63.0 => 5.63.0 orval: ^7.4.0 => 7.4.0 react: ^19.0.0 => 19.0.0 zod: ^3.24.1 => 3.24.1
The text was updated successfully, but these errors were encountered:
Thank you for the quick fix! Confirmed this is no longer an issue in 7.4.1.
Sorry, something went wrong.
anymaniax
Successfully merging a pull request may close this issue.
What are the steps to reproduce this issue?
When generating an orval client with v7.4.0 using TanStack Query and fetch, orval emits an invalid return type for the response data.
In v7.3.0, the return type was
User[] | undefined
, but with v7.4.0 it emits the following type error.Configuration details
The orval config is
and the custom client is
What versions are you using?
The text was updated successfully, but these errors were encountered: