persistedCollectionOptions without a schema can't be passed to createCollection (follow-up to #1452)
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 68/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- typescript
- Bereich
- developer-experience, testing
Rechercherichtung
Start with the persistedCollectionOptions type definitions and the existing type tests in persisted.test-d.ts; the issue says the test "preserves sync-present utility typing" passes never explicitly. Add coverage for the inferred no-schema form used with createCollection, including the guide's Query Collection pattern. Done means the inferred form type-checks without spelling out never, and the type tests pass.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Describe the bug
Wrapping a synced source that has no schema with persistedCollectionOptions fails to type-check when the schema type argument is left to inference. The result can't be passed to createCollection. That includes the Query Collection example in the SQLite persistence guide, as written.
Versions: @tanstack/db 0.15.2, @tanstack/browser-db-sqlite-persistence 0.2.37, TypeScript 7.0.2 (also reproduces on 5.9), strict mode. persisted.ts, types.ts and the collection source are unchanged on main at d2935d0.
To reproduce
import { createCollection, type CollectionConfig } from '@tanstack/db'
import {
createBrowserWASQLitePersistence,
persistedCollectionOptions,
type BrowserWASQLiteDatabase,
} from '@tanstack/browser-db-sqlite-persistence'
type Todo = { id: string; title: string; completed: boolean }
declare const database: BrowserWASQLiteDatabase
const persistence = createBrowserWASQLitePersistence({ database })
const source: CollectionConfig<Todo, string> = {
id: 'rows',
getKey: (row) => row.id,
sync: { sync: ({ markReady }) => markReady() },
}
// Fails with TS2769: No overload matches this call.
// Types of property 'schema' are incompatible.
// Type 'StandardSchemaV1<unknown, unknown> | undefined' is not assignable to type 'undefined'.
createCollection(
persistedCollectionOptions({ ...source, persistence, schemaVersion: 1 }),
)
// Compiles:
createCollection(
persistedCollectionOptions<Todo, string, never>({ ...source, persistence, schemaVersion: 1 }),
)
The guide's example (persistedCollectionOptions<Todo, string>({ ...queryCollectionOptions<Todo, string>({...}), persistence, schemaVersion: 1 })) fails the same way, with Type 'Todo' is not assignable to type 'undefined' on schema.
Expected behavior
A source without a schema should compose with createCollection without spelling out never, as the guide shows.
Notes
When the schema type isn't given, the sync-wrapped overload infers StandardSchemaV1<unknown, unknown> for it, and createCollection's no-schema overload rejects the result. #1866 fixed the schema case from #1452, but the no-schema case still fails. The type test in persisted.test-d.ts ("preserves sync-present utility typing") passes never explicitly, so the inferred form and the guide's example aren't covered. Adding them to the type tests, or passing never in the guide, would close the gap.
I found this while composing the Convex collection from #2230 with SQLite persistence. That PR is not the cause. It type-checks and runs once never and the adapter's utils type are passed explicitly.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 4k
- Forks
- 277
- Ø Merge
- 17 Std. 40 Min.
- Gemergte PRs (30 T.)
- 223
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus TanStack/db
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
Garbage collection cleans up a collection while one of its transactions is still persistingEvtl. vergeben @Nabil372 hat das vor 1 Tag übernommen. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
Maintainer antworten meist innerhalb von 1 Tag
-
Electric: scoped move-in snapshots can prematurely resolve awaitTxId and remove optimistic rowsOffen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 38/100
Maintainer antworten meist innerhalb von 1 Tag
Ähnliche Issues
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
awslabs/visual-asset-management-system#804 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
restatedev/sdk-typescript#813 ·
-
bug desktop P1 session XS
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
Merit-Systems/x402scan#1312 ·
-
type:bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Azure/apiops-cli#331 ·
Maintainer antworten meist innerhalb von 3 Tagen