🎯 Changes#
In monorepo setups you might have something like this:
- packages/db/powersync/schema.ts
- web/db/powersync.ts // new PowerSyncDatabase({database: WaSqlite, schema: SchemaFromSharedPackage}
- expo/db/powersync.ts // new PowerSyncDatabase({database: opSqlite, schema: SchemaFromSharedPackage}
- packages/db/tanstack-db/index.ts
However currently it's not possible to make a function that will take db: AbstractPowerSyncDatabase and return a tanstack collection due to type issues.
Error is:
The inferred type of 'createTanstackCollection' cannot be named without a reference to '../../../../node_modules/@tanstack/powersync-db-collection/dist/esm/helpers'. This is likely not portable. A type annotation is necessary
Collection type looks like this
type SomeCollection = Collection<OptionalExtractedTable<SomeTableType>, string, PowerSyncCollectionUtils<SomeTableType> never,OptionalExtractedTable<SomeTableType>> & NonSingleResult;
The only export missing from @tanstack/powersync-db-collection is OptionalExtractedTable.
Video demonstration of me patching node_modules and the typescript issue going away
https://github.com/user-attachments/assets/d433ad29-2580-4c29-9a47-be089f045e59
✅ Checklist#
🚀 Release Impact#
🦋 Changeset detected#
Latest commit: abd65725d14b95ff4434d30306dead370231a219
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