From 7f6f62a1c943a62ef8c3a9b1232b794d3c30f32c Mon Sep 17 00:00:00 2001 From: Garrett Hardin Date: Thu, 26 Mar 2026 12:09:48 -0700 Subject: [PATCH] fix: normalize schema generic in PersistedSyncOptionsResult for createCollection compatibility `persistedCollectionOptions()` wrapping `queryCollectionOptions()` produced a `PersistedSyncOptionsResult` whose `TSchema` generic didn't match any `createCollection` overload: - With a concrete schema (e.g. ZodObject): `schema?: TSchema | undefined` matched neither the "with schema" overload (`{ schema: T }`) nor the "without schema" overload (`{ schema?: never }`). - Without a schema: `TSchema` defaulted to `StandardSchemaV1` which also failed the `never` check in `createCollection`. Add `NormalizeSchema` helper that collapses both `never` and the default `StandardSchemaV1` to `never`, then use it in both the `CollectionConfig` generic parameter and an intersection that makes `schema` required (concrete) or `schema?: never` (absent). --- .../db-sqlite-persistence-core/src/persisted.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/db-sqlite-persistence-core/src/persisted.ts b/packages/db-sqlite-persistence-core/src/persisted.ts index 236eddb9c..16675676f 100644 --- a/packages/db-sqlite-persistence-core/src/persisted.ts +++ b/packages/db-sqlite-persistence-core/src/persisted.ts @@ -374,14 +374,23 @@ export type PersistedLocalOnlyOptions< schemaVersion?: number } +type NormalizeSchema = + [TSchema] extends [never] + ? never + : [TSchema] extends [StandardSchemaV1] + ? never + : TSchema + type PersistedSyncOptionsResult< T extends object, TKey extends string | number, TSchema extends StandardSchemaV1, TUtils extends UtilsRecord, -> = CollectionConfig & { +> = CollectionConfig, TUtils> & { persistence: PersistedResolvedPersistence -} +} & ([NormalizeSchema] extends [never] + ? { schema?: never } + : { schema: NormalizeSchema }) type PersistedLocalOnlyOptionsResult< T extends object,