mirror of
https://github.com/stablyai/orca.git
synced 2026-11-17 11:24:37 +00:00
fix: retain cache key correlation in the reader type
The second index loses the cache-key correlation across the record union. Assert the identical indexed return type with the structural proof documented; emitted reader code is unchanged.
This commit is contained in:
+2
-1
@@ -26,7 +26,8 @@ type ReferenceCache =
|
||||
|
||||
// Keep long-lived readers out of the read closures' store-snapshot scope.
|
||||
function cacheEntryReader<K extends ReferenceCache>(cache: K, key: string) {
|
||||
return <S extends Pick<AppState, K>>(state: S): S[K][string] | undefined => state[cache]?.[key]
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: both sides index the same cache K; TypeScript loses that correlation at the second index.
|
||||
return (state: AppState) => state[cache]?.[key] as AppState[K][string] | undefined
|
||||
}
|
||||
|
||||
function lookup<T>(
|
||||
|
||||
Reference in New Issue
Block a user