@@ -201,7 +201,7 @@ export class CollectionImpl<T extends object = Record<string, unknown>> {
201201 * This is populated by createCollection
202202 */
203203 public utils : Record < string , Fn > = { }
204- public transactions : Store < SortedMap < string , TransactionType > >
204+ public transactions : Store < SortedMap < string , TransactionType < any > > >
205205 public optimisticOperations : Derived < Array < OptimisticChangeMessage < T > > >
206206 public derivedState : Derived < Map < string , T > >
207207 public derivedArray : Derived < Array < T > >
@@ -250,7 +250,7 @@ export class CollectionImpl<T extends object = Record<string, unknown>> {
250250 }
251251
252252 this . transactions = new Store (
253- new SortedMap < string , TransactionType > (
253+ new SortedMap < string , TransactionType < any > > (
254254 ( a , b ) => a . createdAt . getTime ( ) - b . createdAt . getTime ( )
255255 )
256256 )
@@ -269,7 +269,7 @@ export class CollectionImpl<T extends object = Record<string, unknown>> {
269269 const message : OptimisticChangeMessage < T > = {
270270 type : mutation . type ,
271271 key : mutation . key ,
272- value : mutation . modified as T ,
272+ value : mutation . modified ,
273273 isActive,
274274 }
275275 if (
@@ -684,8 +684,8 @@ export class CollectionImpl<T extends object = Record<string, unknown>> {
684684 const mutation : PendingMutation < T > = {
685685 mutationId : crypto . randomUUID ( ) ,
686686 original : { } ,
687- modified : validatedData as Record < string , unknown > ,
688- changes : validatedData as Record < string , unknown > ,
687+ modified : validatedData ,
688+ changes : validatedData ,
689689 key,
690690 metadata : config ?. metadata as unknown ,
691691 syncMetadata : this . config . sync . getSyncMetadata ?.( ) || { } ,
@@ -710,7 +710,7 @@ export class CollectionImpl<T extends object = Record<string, unknown>> {
710710 return ambientTransaction
711711 } else {
712712 // Create a new transaction with a mutation function that calls the onInsert handler
713- const directOpTransaction = new Transaction ( {
713+ const directOpTransaction = new Transaction < T > ( {
714714 mutationFn : async ( params ) => {
715715 // Call the onInsert handler with the transaction
716716 return this . config . onInsert ! ( params )
@@ -906,10 +906,10 @@ export class CollectionImpl<T extends object = Record<string, unknown>> {
906906 // No need to check for onUpdate handler here as we've already checked at the beginning
907907
908908 // Create a new transaction with a mutation function that calls the onUpdate handler
909- const directOpTransaction = new Transaction ( {
910- mutationFn : async ( transaction ) => {
909+ const directOpTransaction = new Transaction < T > ( {
910+ mutationFn : async ( params ) => {
911911 // Call the onUpdate handler with the transaction
912- return this . config . onUpdate ! ( transaction )
912+ return this . config . onUpdate ! ( params )
913913 } ,
914914 } )
915915
@@ -944,7 +944,7 @@ export class CollectionImpl<T extends object = Record<string, unknown>> {
944944 delete = (
945945 ids : Array < string > | string ,
946946 config ?: OperationConfig
947- ) : TransactionType => {
947+ ) : TransactionType < any > => {
948948 const ambientTransaction = getActiveTransaction ( )
949949
950950 // If no ambient transaction exists, check for an onDelete handler early
@@ -962,9 +962,9 @@ export class CollectionImpl<T extends object = Record<string, unknown>> {
962962 for ( const id of idsArray ) {
963963 const mutation : PendingMutation < T > = {
964964 mutationId : crypto . randomUUID ( ) ,
965- original : ( this . state . get ( id ) || { } ) as Record < string , unknown > ,
966- modified : ( this . state . get ( id ) || { } ) as Record < string , unknown > ,
967- changes : ( this . state . get ( id ) || { } ) as Record < string , unknown > ,
965+ original : this . state . get ( id ) || { } ,
966+ modified : this . state . get ( id ) ! ,
967+ changes : this . state . get ( id ) || { } ,
968968 key : id ,
969969 metadata : config ?. metadata as unknown ,
970970 syncMetadata : ( this . syncedMetadata . state . get ( id ) || { } ) as Record <
@@ -993,11 +993,11 @@ export class CollectionImpl<T extends object = Record<string, unknown>> {
993993 }
994994
995995 // Create a new transaction with a mutation function that calls the onDelete handler
996- const directOpTransaction = new Transaction ( {
996+ const directOpTransaction = new Transaction < T > ( {
997997 autoCommit : true ,
998- mutationFn : async ( transaction ) => {
998+ mutationFn : async ( params ) => {
999999 // Call the onDelete handler with the transaction
1000- return this . config . onDelete ! ( transaction )
1000+ return this . config . onDelete ! ( params )
10011001 } ,
10021002 } )
10031003
0 commit comments