diff --git a/lib/OnyxKeys.ts b/lib/OnyxKeys.ts index 748b717d9..7fa7cf4aa 100644 --- a/lib/OnyxKeys.ts +++ b/lib/OnyxKeys.ts @@ -173,10 +173,11 @@ function getMembersOfCollection(collectionKey: OnyxKey): Set | undefine * @returns A tuple of [collectionKey, memberId] * @throws If the key is not a valid collection member key */ -function splitCollectionMemberKey( +function splitCollectionMemberKey( 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.`); } @@ -190,7 +191,7 @@ function splitCollectionMemberKey