persistedCollectionOptions without a schema can't be passed to createCollection (follow-up to #1452)
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 68/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- typescript
- Área
- developer-experience, testing
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- TypeScript
- Estrellas
- 4k
- Forks
- 277
- Merge medio
- 18 h 49 min
- PR fusionados (30 d)
- 224
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de TanStack/db
-
`Collection.currentStateAsChanges` JSDoc examples don’t match `CurrentStateAsChangesOptions`Abierto
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
OfflineExecutor.dispose() never settles pendingTransactionPromisesPosiblemente ocupada @Claire-ovo la tomó hace 1 día. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
TanStack/db#2254 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 28/100
Los mantenedores suelen responder en 1 día
Todos los issues de TanStack/db
Issues similares
-
category::task code priority::normal
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
e0ipso/strikethroo#145 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 85/100
cocos/cocos-docs#3333 ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
RevenueCat/react-native-purchases#2079 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
RevenueCat/purchases-hybrid-common#2039 ·
Los mantenedores suelen responder en 1 día
-
agent-reported area/react bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día