TanStackT
TanStack4w ago
3 replies
wet-aqua

useQuery data unknown if spreading queryOptions and adding queryFn

Not quite sure if this is to be expected or an issue to file
, but noticed this when trying to centralize a queryOptions object so that i can use it as a key, but add a queryFn when calling it w/useQuery. If the queryFn was added after the spread, then the data was unknown, if it was part of the queryOptions data returns properly typed.

playground - https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAbzgRwK4FMoE8DyYbAQB2AzgDRyonoCKG2cAvnAGZQQhwDkAAjAIakBAYwDWAeijp+wmAFo0mLFwBQoSLDgAqOPxJwAStNmt2nLlJkxVK4cRLwYEACYQ6SvAXtwAvHBUIKnC6ADYhAFwA2lxOriRcALq6+nZCZEFwAO7AMAAWEKgw4XAAFACUvgB8KPS4+ISkJYHBwYrYANLoWMWRAHT9sW61ng0kvfxhcBRc6Dn5hYnJcKkOGYxl6dl5xeVVNR719k0ZbVid3XB9Ay5DB16k42HTW7mLesv2MOmttQBiRHBwrsfNVTuUVOsISoVCxUERZA19thds04FIYKgoACAApmYDUXpSEgQEIAN3QJQs6GJZPQzi4ZQh-hhcIRxDgAEEwGAUdDgitHDd3NgAOpzArwPxUWi1Y4tOD9XqDYV1e5jF4S8oUDI-JT-HYVEFIrDg4KQ2yfODK2pivK+SjUFUla13Ua9F7lRkZdGYgElHVwAA8zmApMqAeCDlQLBYAcD4hDYYyjMYQA

if you hover over the query that tacks on the queryFn, data is unknown. The query with the queryFn as part of the queryOptions is aok.
Thanks!
The Playground lets you write TypeScript or JavaScript online in a safe and sharable way.
Was this page helpful?