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

Export QueryKey type from generated tanstack query client #1705

Open
lsdch opened this issue Feb 11, 2025 · 0 comments
Open

Export QueryKey type from generated tanstack query client #1705

lsdch opened this issue Feb 11, 2025 · 0 comments
Labels
feature 🚀 New feature or request

Comments

@lsdch
Copy link
Contributor

lsdch commented Feb 11, 2025

Description

Would be nice to have for passing query options around. I'm using tanstack vue query client (and it's awesome), made a generic component that takes a query option as prop, but I had to copy-paste QueryKey type from the client to make the compiler happy:

interface DatasetQueryData {
  headers?: {
    Authorization: string
  }
  path: {
    slug: string
  }
}

type QueryKey<TOptions extends Options> = [
  Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & {
    _id: string
    _infinite?: boolean
  }
]

const { slug, query } = defineProps<{
  slug: string
  query: (options: OptionsLegacyParser<DatasetQueryData>) => UndefinedInitialQueryOptions<
    DatasetType,
    ErrorModel,
    DatasetType,
    QueryKey<DatasetQueryData>
  > & {
    queryKey: QueryKey<DatasetQueryData>
  }
}>()
@lsdch lsdch added the feature 🚀 New feature or request label Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 🚀 New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant