TanStackT
TanStack11mo ago
2 replies
sacred-rose

useQuery() Typescript says only data is returned, not | undefined?

The docs state that the data type should be T | undefined. In our codebase however, data is not optional (see image), it is just T.
Does anyone know why this is the case?
Screen_Shot_2025-03-05_at_12.43.47_PM.png
React Query is now written in TypeScript to make sure the library and your projects are type-safe! Things to keep in mind: Types currently require using TypeScript v4.1 or greater Changes to types in...
TypeScript | TanStack Query React Docs
Was this page helpful?