TanStackT
TanStack2mo ago
8 replies
sacred-emerald

Defining and using an abstract collection type

A shared service used across apps expects an input of type Collection<T>, where T is a shared type definition of an object.
The service uses the input collection to query and manipulate the underlying collection, while abstracting the logic of fetching and persisting data. The individual apps can supply any collection they like, as long as the items in that collection match T.

How is this best achieved? When typing the input strictly as Collection<T>, I get various type issues, including the insert mutation transaction not propagating the row type. Instead it is typed as Record<string, any>
Was this page helpful?