Skip to content
Source
Sign inSign up
TanStack/db

fix(powersync-db-collection): additional export to make type definitions portable #1277

Closedillkle(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/1277/headopened

🎯 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

  • I have tested this code locally with pnpm test.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).
    1. 🦋 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
      NameType
      @tanstack/powersync-db-collectionMinor

      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

    2. Closing as superseded by merged PR #1831, which includes portable public declarations together with the PowerSync 2 runtime and typing repairs, and preserves the original contributor credit.

Sign in to join this conversation.