-
Notifications
You must be signed in to change notification settings - Fork 115
Loosen type for collections in offline transactions #774
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
base: main
Are you sure you want to change the base?
Loosen type for collections in offline transactions #774
Conversation
|
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: |
|
Size Change: 0 B Total Size: 79.8 kB ℹ️ View Unchanged
|
|
Size Change: 0 B Total Size: 3.34 kB ℹ️ View Unchanged
|
…lectionOptions Fixes #761 Previously, when using queryCollectionOptions with startOfflineExecutor, TypeScript would throw a type error due to Collection type parameter variance. The issue occurred because: - queryCollectionOptions creates Collection<ConcreteType, string> - OfflineConfig expected Record<string, Collection> which defaults to Collection<Record<string, unknown>, string | number> - TypeScript couldn't assign the more specific collection type to the more general expected type due to function parameter contravariance Solution: Updated OfflineConfig and related classes to explicitly accept Collection<any, any, any, any, any> to allow collections of any specific type to be passed in. This is safe because the offline executor only accesses collection.id and doesn't call any type-specific methods like getKey directly. Changes: - OfflineConfig.collections type updated - OutboxManager constructor parameter type updated - TransactionSerializer constructor and field types updated
98587e5 to
c37fb4a
Compare
It should accept any collection.
Fixes #761
Previously, when using queryCollectionOptions with startOfflineExecutor, TypeScript would throw a type error due to Collection type parameter variance.
The issue occurred because:
Solution:
Updated OfflineConfig and related classes to explicitly accept Collection<any, any, any, any, any> to allow collections of any specific type to be passed in.
This is safe because the offline executor only accesses collection.id and doesn't call any type-specific methods like getKey directly.
Changes:
🎯 Changes
✅ Checklist
pnpm test:pr.🚀 Release Impact