Skip to content

Conversation

@isoppp
Copy link

@isoppp isoppp commented Nov 27, 2025

Summary

  • Remove undefined from useSuspenseQuery data type
  • Generate type definitions that comply with TanStack Query's official specification

Fixes #181

Changes

Type Fixes

  • Add UseSuspenseQueryOptions import
  • Wrap DefaultResponse type with NonNullable for suspense queries
  • Use UseSuspenseQueryOptions for suspense query options parameter

Generated Code Changes

Before:

export const useFindPetsSuspense = <
  TData = Common.FindPetsDefaultResponse,  // includes undefined
  ...
>(
  options?: Omit<UseQueryOptions<TData, TError>, ...>,
) => ...

After:

export const useFindPetsSuspense = <
  TData = NonNullable<Common.FindPetsDefaultResponse>,  // excludes undefined
  ...
>(
  options?: Omit<UseSuspenseQueryOptions<TData, TError>, ...>,
) => ...

Why NonNullable?

useSuspenseQuery enforces throwOnError: true, so errors are thrown and caught by ErrorBoundary. This means data is guaranteed to be defined when the component renders. Wrapping with NonNullable removes undefined from the type while maintaining consistency with the existing Common.* type reference pattern.

How to Test

  • Run pnpm build
  • Run pnpm vitest run
  • Run pnpm run generate:api && pnpm run test:generated in examples/react-app
  • Verify generated suspense hooks allow data.map() without optional chaining

@vercel
Copy link

vercel bot commented Nov 27, 2025

@isoppp is attempting to deploy a commit to the Daiki Urata's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

useSuspenseQuery must not contain undefined type for data

1 participant