Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/OnyxKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,11 @@ function getMembersOfCollection(collectionKey: OnyxKey): Set<OnyxKey> | undefine
* @returns A tuple of [collectionKey, memberId]
* @throws If the key is not a valid collection member key
*/
function splitCollectionMemberKey<TKey extends CollectionKey, CollectionKeyType = TKey extends `${infer Prefix}_${string}` ? `${Prefix}_` : never>(
function splitCollectionMemberKey<TKey extends CollectionKey>(
key: TKey,
collectionKey?: string,
): [CollectionKeyType, string] {
): [TKey extends `${infer Prefix}_${string}` ? `${Prefix}_` : never, string];
function splitCollectionMemberKey(key: string, collectionKey?: string): [string, string] {
if (collectionKey && !isCollectionMemberKey(collectionKey, key)) {
throw new Error(`Invalid '${collectionKey}' collection key provided, it isn't compatible with '${key}' key.`);
}
Expand All @@ -190,7 +191,7 @@ function splitCollectionMemberKey<TKey extends CollectionKey, CollectionKeyType
collectionKey = resolvedKey;
}

return [collectionKey as CollectionKeyType, key.slice(collectionKey.length)];
return [collectionKey, key.slice(collectionKey.length)];
}

/**
Expand Down
Loading