persistedCollectionOptions without a schema can't be passed to createCollection (follow-up to #1452)
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 68/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- typescript
- Domínio
- developer-experience, testing
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- TypeScript
- Estrelas
- 4k
- Forks
- 277
- Merge médio
- 17h 40min
- PRs com merge (30d)
- 223
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de TanStack/db
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
Mantenedores costumam responder em até 1 dia
-
Garbage collection cleans up a collection while one of its transactions is still persistingTalvez já em andamento @Nabil372 assumiu há 1 dia. Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 35/100
Mantenedores costumam responder em até 1 dia
-
Electric: scoped move-in snapshots can prematurely resolve awaitTxId and remove optimistic rowsAberta
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 38/100
Mantenedores costumam responder em até 1 dia
Todas as issues de TanStack/db
Issues semelhantes
-
type: bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 79/100
Mantenedores costumam responder em até 1 dia
-
0️⃣ phase/new
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 70/100
microsoft/playwright#43640 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100