Describe the bug
Some type information gets lost in TransactionWithMutations['mutations'] when used with array methods such as .map().
To Reproduce
constschema=z.object({id: z.string(),title: z.string(),completed: z.boolean(),});consttodosCollection=createCollection(electricCollectionOptions({id: 'todos',
schema,getKey: (item)=>item.id,shapeOptions: {url: '/api/todos',params: {table: 'todos'},},onDelete: async({ transaction })=>{awaitPromise.all(transaction.mutations.map((mutation)=>// ❌ `original` is typed as `{} | { id: string; title: string; completed: boolean; }`api.todos.delete(mutation.original.id),),);// ✅ `original` is typed as `{ id: string; title: string; completed: boolean; }`awaitapi.todos.delete(transaction.mutations[0].original.id);// ✅ `original` is typed as `{ id: string; title: string; completed: boolean; }`awaitapi.todos.delete(transaction.mutations[1]!.original.id);},}),);Expected behavior
The type of transaction.mutations.map((mutation) => mutation.original)[0] should match transaction.mutations[0].original.
Additional context
Omitting mutations from Transaction<T> in TransactionWithMutations does the trick:
exporttypeTransactionWithMutations<Textendsobject=Record<string,unknown>,TOperationextendsOperationType=OperationType>=Omit<Transaction<T>,'mutations'>&{mutations: NonEmptyArray<PendingMutation<T,TOperation>>;};
Describe the bug
Some type information gets lost in
TransactionWithMutations['mutations']when used with array methods such as.map().To Reproduce
Expected behavior
The type of
transaction.mutations.map((mutation) => mutation.original)[0]should matchtransaction.mutations[0].original.Additional context
Omitting
mutationsfromTransaction<T>inTransactionWithMutationsdoes the trick: