@@ -5,7 +5,7 @@ import waitForPromisesToResolve from '../utils/waitForPromisesToResolve';
55import OnyxUtils from '../../lib/OnyxUtils' ;
66import type OnyxCache from '../../lib/OnyxCache' ;
77import StorageMock from '../../lib/storage' ;
8- import type { OnyxCollection , OnyxUpdate } from '../../lib/types' ;
8+ import type { OnyxCollection , OnyxKey , OnyxMergeCollectionInput , OnyxUpdate } from '../../lib/types' ;
99import type { GenericDeepRecord } from '../types' ;
1010import type GenericCollection from '../utils/GenericCollection' ;
1111import type { Connection } from '../../lib/OnyxConnectionManager' ;
@@ -624,7 +624,7 @@ describe('Onyx', () => {
624624 ID : 345 ,
625625 value : 'three' ,
626626 } ,
627- } as GenericCollection )
627+ } as unknown as OnyxMergeCollectionInput < OnyxKey > )
628628 . then ( ( ) =>
629629 // 2 key values to update and 2 new keys to add.
630630 // MergeCollection will perform a mix of multiSet and multiMerge
@@ -646,7 +646,7 @@ describe('Onyx', () => {
646646 ID : 567 ,
647647 value : 'one' ,
648648 } ,
649- } as GenericCollection ) ,
649+ } as unknown as OnyxMergeCollectionInput < OnyxKey > ) ,
650650 )
651651 . then ( ( ) => {
652652 // 3 items on the first mergeCollection + 4 items the next mergeCollection
@@ -674,7 +674,7 @@ describe('Onyx', () => {
674674 callback : ( data , key ) => ( valuesReceived [ key ] = data ) ,
675675 } ) ;
676676
677- return Onyx . mergeCollection ( ONYX_KEYS . COLLECTION . TEST_KEY , { test_1 : { ID : 123 } , notMyTest : { beep : 'boop' } } as GenericCollection ) . then ( ( ) => {
677+ return Onyx . mergeCollection ( ONYX_KEYS . COLLECTION . TEST_KEY , { test_1 : { ID : 123 } , notMyTest : { beep : 'boop' } } as unknown as OnyxMergeCollectionInput < OnyxKey > ) . then ( ( ) => {
678678 expect ( valuesReceived ) . toEqual ( { } ) ;
679679 } ) ;
680680 } ) ;
@@ -705,7 +705,7 @@ describe('Onyx', () => {
705705 ID : 234 ,
706706 value : 'two' ,
707707 } ,
708- } as GenericCollection ) ,
708+ } as unknown as OnyxMergeCollectionInput < OnyxKey > ) ,
709709 )
710710 . then ( ( ) => {
711711 expect ( valuesReceived ) . toEqual ( {
@@ -899,7 +899,7 @@ describe('Onyx', () => {
899899 ID : 345 ,
900900 value : 'three' ,
901901 } ,
902- } ,
902+ } as unknown as OnyxMergeCollectionInput < OnyxKey > ,
903903 } ,
904904 ] ) ;
905905 } )
@@ -1058,7 +1058,7 @@ describe('Onyx', () => {
10581058 } ,
10591059 } ;
10601060
1061- return Onyx . mergeCollection ( ONYX_KEYS . COLLECTION . TEST_CONNECT_COLLECTION , initialCollectionData as GenericCollection )
1061+ return Onyx . mergeCollection ( ONYX_KEYS . COLLECTION . TEST_CONNECT_COLLECTION , initialCollectionData as unknown as OnyxMergeCollectionInput < OnyxKey > )
10621062 . then ( ( ) => {
10631063 // When we connect to that collection with waitForCollectionCallback = true
10641064 connection = Onyx . connect ( {
@@ -1091,7 +1091,7 @@ describe('Onyx', () => {
10911091 return (
10921092 waitForPromisesToResolve ( )
10931093 // When mergeCollection is called with an updated collection
1094- . then ( ( ) => Onyx . mergeCollection ( ONYX_KEYS . COLLECTION . TEST_POLICY , collectionUpdate as GenericCollection ) )
1094+ . then ( ( ) => Onyx . mergeCollection ( ONYX_KEYS . COLLECTION . TEST_POLICY , collectionUpdate as unknown as OnyxMergeCollectionInput < OnyxKey > ) )
10951095 . then ( ( ) => {
10961096 // Then we expect the callback to have called twice, once for the initial connect call + once for the collection update
10971097 expect ( mockCallback ) . toHaveBeenCalledTimes ( 2 ) ;
@@ -1120,7 +1120,7 @@ describe('Onyx', () => {
11201120 return (
11211121 waitForPromisesToResolve ( )
11221122 // When mergeCollection is called with an updated collection
1123- . then ( ( ) => Onyx . mergeCollection ( ONYX_KEYS . COLLECTION . TEST_POLICY , collectionUpdate as GenericCollection ) )
1123+ . then ( ( ) => Onyx . mergeCollection ( ONYX_KEYS . COLLECTION . TEST_POLICY , collectionUpdate as unknown as OnyxMergeCollectionInput < OnyxKey > ) )
11241124 . then ( ( ) => {
11251125 // Then we expect the callback to have called twice, once for the initial connect call + once for the collection update
11261126 expect ( mockCallback ) . toHaveBeenCalledTimes ( 2 ) ;
@@ -1268,7 +1268,7 @@ describe('Onyx', () => {
12681268 Onyx . update ( [
12691269 { onyxMethod : Onyx . METHOD . SET , key : ONYX_KEYS . TEST_KEY , value : 'taco' } ,
12701270 { onyxMethod : Onyx . METHOD . MERGE , key : ONYX_KEYS . OTHER_TEST , value : 'pizza' } ,
1271- { onyxMethod : Onyx . METHOD . MERGE_COLLECTION , key : ONYX_KEYS . COLLECTION . TEST_UPDATE , value : { [ itemKey ] : { a : 'a' } } } ,
1271+ { onyxMethod : Onyx . METHOD . MERGE_COLLECTION , key : ONYX_KEYS . COLLECTION . TEST_UPDATE , value : { [ itemKey ] : { a : 'a' } } as OnyxMergeCollectionInput < OnyxKey > } ,
12721272 ] ) . then ( ( ) => {
12731273 expect ( collectionCallback ) . toHaveBeenCalledTimes ( 2 ) ;
12741274 expect ( collectionCallback ) . toHaveBeenNthCalledWith ( 1 , undefined , undefined , undefined ) ;
@@ -1525,10 +1525,10 @@ describe('Onyx', () => {
15251525
15261526 const initialValue = { name : 'Fluffy' } ;
15271527
1528- const collectionDiff : GenericCollection = {
1528+ const collectionDiff = {
15291529 [ cat ] : initialValue ,
15301530 [ dog ] : { name : 'Rex' } ,
1531- } ;
1531+ } as OnyxMergeCollectionInput < OnyxKey > ;
15321532
15331533 return Onyx . set ( cat , initialValue )
15341534 . then ( ( ) => {
@@ -1630,7 +1630,7 @@ describe('Onyx', () => {
16301630 0 : 'Bed' ,
16311631 } ,
16321632 } ,
1633- } ,
1633+ } as OnyxMergeCollectionInput < OnyxKey > ,
16341634 } ,
16351635 {
16361636 onyxMethod : Onyx . METHOD . MERGE ,
@@ -1729,7 +1729,7 @@ describe('Onyx', () => {
17291729 value : {
17301730 [ cat ] : { age : 5 , size : 'S' } ,
17311731 [ dog ] : { size : 'M' } ,
1732- } ,
1732+ } as OnyxMergeCollectionInput < OnyxKey > ,
17331733 } ,
17341734 { onyxMethod : Onyx . METHOD . SET , key : cat , value : { age : 3 } } ,
17351735 { onyxMethod : Onyx . METHOD . MERGE , key : cat , value : { sound : 'meow' } } ,
@@ -2214,7 +2214,7 @@ describe('Onyx', () => {
22142214 value : {
22152215 [ routeA ] : { name : 'New Route A' } ,
22162216 [ routeB ] : { name : 'New Route B' } ,
2217- } ,
2217+ } as OnyxMergeCollectionInput < OnyxKey > ,
22182218 } ,
22192219 ] ) ;
22202220 } )
@@ -2265,7 +2265,7 @@ describe('Onyx', () => {
22652265 key : ONYX_KEYS . COLLECTION . ROUTES ,
22662266 value : {
22672267 [ routeA ] : { name : 'Final Route A' } ,
2268- } ,
2268+ } as OnyxMergeCollectionInput < OnyxKey > ,
22692269 } ,
22702270 {
22712271 onyxMethod : Onyx . METHOD . MERGE ,
@@ -2319,7 +2319,7 @@ describe('Onyx', () => {
23192319 value : {
23202320 [ key1 ] : { id : '1' , name : 'Updated Item 1' } ,
23212321 [ key2 ] : { id : '2' , name : 'Updated Item 2' } ,
2322- } ,
2322+ } as OnyxMergeCollectionInput < OnyxKey > ,
23232323 } ,
23242324 ] ) ;
23252325
@@ -2663,8 +2663,9 @@ describe('Onyx', () => {
26632663 } as GenericCollection ) ;
26642664
26652665 await Onyx . setCollection ( ONYX_KEYS . COLLECTION . ROUTES , {
2666+ // @ts -expect-error invalidRoute is not a valid key
26662667 [ invalidRoute ] : { name : 'Invalid Route' } ,
2667- } as GenericCollection ) ;
2668+ } ) ;
26682669
26692670 expect ( result ) . toEqual ( {
26702671 [ routeA ] : { name : 'Route A' } ,
0 commit comments