fix(query-db-collection): align queryOptions interop types#1287
fix(query-db-collection): align queryOptions interop types#1287hugiex wants to merge 4 commits intoTanStack:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 7a3becc The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
More templates
@tanstack/angular-db
@tanstack/db
@tanstack/db-ivm
@tanstack/electric-db-collection
@tanstack/offline-transactions
@tanstack/powersync-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/rxdb-db-collection
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
| `queryFn` | `queryKey` | ||
| > & { | ||
| queryKey: TaggedQueryKey<TQueryKey, TQueryData, TError> | ||
| queryFn?: ( |
There was a problem hiding this comment.
The types should correspond to runtime expectations. The query function is required at runtime so this should be reflected by the type, even if that is incompatible with TanStack query options.
There was a problem hiding this comment.
make sense, I've made the changes
|
Thanks for the suggestion! I'm totally good with simplifying it if this already covers what we need. Happy to stick with the minimal approach as long as it fits the repo/team direction. I'll go ahead and close this PR 👍 |
Summary
To fix this issue: #1279
This PR makes
queryOptions(...)interop first-class in@tanstack/query-db-collection. You can now spread...queryOptions(...)intoqueryCollectionOptions(...)without re-declaringqueryKey, re-shapingenabled, or wrappingqueryFn.🎯 Changes
queryFnnow acceptsT | Promise<T>(not Promise-only).enablednow aligns withQueryObserverOptions['enabled'](boolean or callback).staleTime,refetchInterval,retry, andretryDelaynow followQueryObserverOptionstyping with the correct query data/key generics.DataTagquery keys returned byqueryOptions(...).queryFnis still required at runtime.selectto extract item arrays.queryFnreturn support).queryOptions(...)spread usage.SkipTokensupport (query collections require an executable fetch function).Why
The issue is a type-level mismatch between
query-db-collectionand TanStack Query option shapes. This removes boilerplate for existing Query users while preserving query-collection safety guarantees.Reference: original TanStack Query types file
✅ Checklist
pnpm test.Note: there are some failed test files but I didn't changes them
🚀 Release Impact