Tengo un caché que usa mi aplicación y el caché está envuelto en un Proxy que administra la validación de vencimiento.
Estas son algunas de las definiciones de lista de mi archivo Lists.d.ts como referencia, pero no creo que el problema exista aquí.
interface MetaData { Title: string | null; FileSystemObjectType: number; Id: number; // .... } // The CreationProps types just define the fields in the object type DeviceCreationProps = { Model: string; Manufacturer: string; // ... }; type CommentData = MetaData & CommentCreationProps; type DeviceData = MetaData & DeviceCreationProps; type UserData = MetaData & UserCreationProps; type ListDataMap = { Comments: CommentData; Devices: DeviceData; Users: UserData; }; type ListName = keyof ListDataMap;Ahora en mi archivo ListItemCache.ts tengo el siguiente código:
type CacheExpirationMapValue = { // [list name] : expiration date object [List in ListName]?: Date; }; const CacheExpirationMap: CacheExpirationMapValue = {}; type RawListItemCacheValue = { // [name of list]: array of list items [List in ListName]?: ListDataMap[List][]; }; const RawListItemCache: RawListItemCacheValue = {}; const maxAge = 1000 * 60 * 5; // This is a proxied object that allows us to handle the expirations when fetching cached objects const ListItemCache = new Proxy(RawListItemCache, { set<List extends ListName>(obj, prop: List, value: ListDataMap[List][]) { const expires = new Date(Date.now() + maxAge); CacheExpirationMap[prop] = expires; obj[prop] = value; return true; }, get(obj, prop) { const item = obj[prop]; const now = new Date(); if (item && !!CacheExpirationMap[prop] && CacheExpirationMap[prop] > now) { return item; } return []; }, }); export default ListItemCache;Todo está bien y no tengo ningún problema en este archivo, pero cuando trato de establecer el valor del caché en otro archivo, por ejemplo:
export default function usePopulateCache<List extends ListName>(list: List) { const { sp } = useContext(SPContext); useEffect(() => { sp.web.lists .getByTitle(list) .items<ListDataMap[List][]>() .then((items) => { ListItemCache[list] = items; }); }, []); } Me sale el siguiente error en la tarea: 
No estoy seguro de por qué esto se debe a que el tipo de Lista que indexa a ambos es el mismo y RawListItemCacheValue[List] debe ser el mismo que ListDataMap[List][] según su definición de tipo.