Can Typescript automatically declare a type that retrieves the inner type of an array?
For instance:
Assume the following code snippet already exists:
export interface Cache {
events: Event[],
users: User[]
}
type CacheType = Event[] | User[];
//or maybe:
// type TypeOfProperty = T[keyof T];
// type CacheType = TypeOfProperty<Cache>;
What I am looking for is something like this:
type InnerCacheType = Event | User;
But without the need to manually update it every time a new item is added to Cache
or CacheType
Is this functionality supported in Typescript?