Skip to content

How to properly type useQuery's meta? #6045

Answered by TkDodo
denisborovikov asked this question in Q&A
Discussion options

You must be logged in to vote

we don't have a generic for meta so its type cannot be inferred. In v5, you can use module augmentation:

declare module '@tanstack/react-query' {
  interface Register {
    queryMeta: Meta
    mutationMeta: Record<string, unknown>
  }
}

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
3 replies
@denisborovikov
Comment options

@joel-daros
Comment options

@charliematters
Comment options

Answer selected by denisborovikov
Comment options

You must be logged in to vote
1 reply
@TkDodo
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants