Skip to content
New issue

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

The auto-complete feature on useQuery did not work as expected #7209

Closed
ienrum opened this issue Apr 1, 2024 · 2 comments · Fixed by #7260
Closed

The auto-complete feature on useQuery did not work as expected #7209

ienrum opened this issue Apr 1, 2024 · 2 comments · Fixed by #7260
Labels

Comments

@ienrum
Copy link
Contributor

ienrum commented Apr 1, 2024

Describe the bug

When I use the useQuery hook and provide it with initialData, the autocomplete feature doesn't work.

Your minimal, reproducible example

https://www.typescriptlang.org/ko/play?#code/JYWwDg9gTgLgBAbzgVwM4FMCKz1QJ5wC+cAZlBCHAOQACMAhgHaoMDGA1gPRTr2swBaAI458VANwAoScEYxcJPujgAVALJ4AIvQaJJcOABMd9VAC49Bg8EMXGyEACNcUg4SmFprCM3hp0AKIAHvTgADZYogQAvHAAFACUcNEAfJZw3r6IRiYW6CHh6Nq6xLH+2Lh4ADzqWiYpcQj6ViKVANLoeBYA2lQgeALsnVQAugA0zQat+ABijBaJyWmNk1bGDObZNhYAjEQTVkQJB1aywDDA9GHF9BZNhwbrpnerh9twOwBMJ4eEP-vNQgJKTNHgwZBQRhwfKhMARG4eEH5SCwIzoRTIMJ+DDBWERCr4KRAA

Steps to reproduce

  1. Use useQuery hooks
  2. Provide initialData option
  3. Auto-complete not working when provided

Expected behavior

it should be auto-completed.

How often does this bug happen?

Every time

Screenshots or Videos

image

Platform

  • Os: Windows
  • Browser: 123.0.6312.86

Tanstack Query adapter

react-query

TanStack Query version

^5.18.1

TypeScript version

5.3.3

Additional context

I suggest just reordering the useQuery function declarations and specifying that DefinedInitialDataOptions is higher order than UnDefinedInitialDataOptions in the options declaration.

like this

export function useQuery<
  TQueryFnData = unknown,
  TError = DefaultError,
  TData = TQueryFnData,
  TQueryKey extends QueryKey = QueryKey,
>(
  options: DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError>

export function useQuery<
  TQueryFnData = unknown,
  TError = DefaultError,
  TData = TQueryFnData,
  TQueryKey extends QueryKey = QueryKey,
>(
  options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,
  queryClient?: QueryClient,
): UseQueryResult<TData, TError>
@TkDodo
Copy link
Collaborator

TkDodo commented Apr 10, 2024

I suggest just reordering the useQuery function declarations and specifying that DefinedInitialDataOptions is higher order than UnDefinedInitialDataOptions in the options declaration.

if that works, can you PR it please ?

@TkDodo TkDodo added the types label Apr 10, 2024
@ienrum
Copy link
Contributor Author

ienrum commented Apr 10, 2024

yes, of course!

@TkDodo TkDodo linked a pull request Apr 11, 2024 that will close this issue
@TkDodo TkDodo closed this as completed Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants