Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

persistedCollectionOptions without a schema can't be passed to createCollection (follow-up to #1452)

Aperta
#2,255 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@jp-knj ci sta già lavorando.

Dal 26/10/2026.

  • #2259 di @jp-knj — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
TypeScript
Stelle
4k
Fork
277
Merge medio
17h 40m
PR unite (30g)
223

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di TanStack/db

Tutte le issue di TanStack/db

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.