Skip to content

Commit cb08498

Browse files
committed
Fix type errors while building onyx
1 parent 2e98c2c commit cb08498

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

lib/Onyx.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ function update(data: OnyxUpdate[]): Promise<void> {
558558
collectionKeys.forEach((collectionKey) => enqueueMergeOperation(collectionKey, mergedCollection[collectionKey]));
559559
}
560560
},
561-
[OnyxUtils.METHOD.SET_COLLECTION]: (k, v) => promises.push(() => setCollection(k, v as Collection<CollectionKey, unknown>)),
561+
[OnyxUtils.METHOD.SET_COLLECTION]: (k, v) => promises.push(() => setCollection(k, v as OnyxMergeCollectionInput<OnyxKey>)),
562562
[OnyxUtils.METHOD.MULTI_SET]: (k, v) => Object.entries(v as Partial<OnyxInputKeyValueMapping>).forEach(([entryKey, entryValue]) => enqueueSetOperation(entryKey, entryValue)),
563563
[OnyxUtils.METHOD.CLEAR]: () => {
564564
clearPromise = clear();
@@ -611,14 +611,14 @@ function update(data: OnyxUpdate[]): Promise<void> {
611611
promises.push(() =>
612612
OnyxUtils.mergeCollectionWithPatches(
613613
collectionKey,
614-
batchedCollectionUpdates.merge as Collection<CollectionKey, unknown>,
614+
batchedCollectionUpdates.merge as OnyxMergeCollectionInput<OnyxKey>,
615615
batchedCollectionUpdates.mergeReplaceNullPatches,
616616
true,
617617
),
618618
);
619619
}
620620
if (!utils.isEmptyObject(batchedCollectionUpdates.set)) {
621-
promises.push(() => OnyxUtils.partialSetCollection(collectionKey, batchedCollectionUpdates.set as Collection<CollectionKey, unknown>));
621+
promises.push(() => OnyxUtils.partialSetCollection(collectionKey, batchedCollectionUpdates.set as OnyxMergeCollectionInput<OnyxKey>));
622622
}
623623
});
624624

lib/OnyxUtils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import type {
2929
OnyxUpdate,
3030
OnyxValue,
3131
Selector,
32+
Collection,
3233
} from './types';
3334
import type {FastMergeOptions, FastMergeResult} from './utils';
3435
import utils from './utils';
@@ -1035,7 +1036,7 @@ function initializeWithDefaultKeyStates(): Promise<void> {
10351036
/**
10361037
* Validate the collection is not empty and has a correct type before applying mergeCollection()
10371038
*/
1038-
function isValidNonEmptyCollectionForMerge<TKey extends CollectionKeyBase>(collection: OnyxMergeCollectionInput<TKey>): boolean {
1039+
function isValidNonEmptyCollectionForMerge<TKey extends CollectionKeyBase>(collection: Collection<TKey, unknown>): boolean {
10391040
return typeof collection === 'object' && !Array.isArray(collection) && !utils.isEmptyObject(collection);
10401041
}
10411042

@@ -1350,7 +1351,7 @@ function mergeCollectionWithPatches<TKey extends CollectionKeyBase>(
13501351
});
13511352

13521353
return Promise.all(promises)
1353-
.catch((error) => evictStorageAndRetry(error, mergeCollectionWithPatches, collectionKey, resultCollection))
1354+
.catch((error) => evictStorageAndRetry(error, mergeCollectionWithPatches, collectionKey, resultCollection as OnyxMergeCollectionInput<TKey>))
13541355
.then(() => {
13551356
sendActionToDevTools(METHOD.MERGE_COLLECTION, undefined, resultCollection);
13561357
return promiseUpdate;

0 commit comments

Comments
 (0)