openapi-react-query-codegen icon indicating copy to clipboard operation
openapi-react-query-codegen copied to clipboard

`useSuspenseQuery` must not contain `undefined` type for data

Open kbumsik opened this issue 8 months ago • 0 comments

Describe the bug

Generated type of useSuspenseQuery's data (TData) must not contain undefined unlike useQuery.

This is the point of using useSuspenseQuery. TanStack Query document clearly states that

const { data } = useSuspenseQuery({ queryKey, queryFn }) This works nicely in TypeScript, because data is guaranteed to be defined (as errors and loading states are handled by Suspense- and ErrorBoundaries).

To Reproduce

Generate anything with 2.0.0-beta.3

Expected behavior

Generated suspend queries's data must be non-nullable.

Maybe just add NonNullable<> around TData?

kbumsik avatar Mar 28 '25 12:03 kbumsik