@@ -10,12 +10,12 @@ class OnyxSnapshotCache {
1010 /**
1111 * Snapshot cache for ultimate performance - separate cache per Onyx key
1212 */
13- private snapshotCache : Map < string , Map < string , any > > ;
13+ private snapshotCache : Map < string , Map < string , unknown > > ;
1414
1515 /**
1616 * Maps selector functions to unique IDs for cache key generation
1717 */
18- private selectorIdMap : Map < UseOnyxSelector < any , any > , string > ;
18+ private selectorIdMap : Map < UseOnyxSelector < OnyxKey , unknown > , string > ;
1919
2020 /**
2121 * Counter for generating incremental selector IDs
@@ -31,12 +31,13 @@ class OnyxSnapshotCache {
3131 /**
3232 * Generate unique ID for selector functions using incrementing numbers
3333 */
34- getSelectorId ( selector : UseOnyxSelector < any , any > ) : string {
35- if ( ! this . selectorIdMap . has ( selector ) ) {
34+ getSelectorId < TKey extends OnyxKey , TReturnValue > ( selector : UseOnyxSelector < TKey , TReturnValue > ) : string {
35+ const typedSelector = selector as unknown as UseOnyxSelector < OnyxKey , unknown > ;
36+ if ( ! this . selectorIdMap . has ( typedSelector ) ) {
3637 const id = `selector_${ this . selectorIdCounter ++ } ` ;
37- this . selectorIdMap . set ( selector , id ) ;
38+ this . selectorIdMap . set ( typedSelector , id ) ;
3839 }
39- return this . selectorIdMap . get ( selector ) ! ;
40+ return this . selectorIdMap . get ( typedSelector ) ! ;
4041 }
4142
4243 /**
@@ -54,15 +55,15 @@ class OnyxSnapshotCache {
5455 /**
5556 * Get cached snapshot result for a key and cache key combination
5657 */
57- getCachedResult ( key : string , cacheKey : string ) : any {
58+ getCachedResult < T > ( key : string , cacheKey : string ) : T | undefined {
5859 const keyCache = this . snapshotCache . get ( key ) ;
59- return keyCache ?. get ( cacheKey ) ;
60+ return keyCache ?. get ( cacheKey ) as T | undefined ;
6061 }
6162
6263 /**
6364 * Set cached snapshot result for a key and cache key combination
6465 */
65- setCachedResult ( key : string , cacheKey : string , result : any ) : void {
66+ setCachedResult < T > ( key : string , cacheKey : string , result : T ) : void {
6667 if ( ! this . snapshotCache . has ( key ) ) {
6768 this . snapshotCache . set ( key , new Map ( ) ) ;
6869 }
0 commit comments