Is there a way to declare a type in typescript that 'extracts' the inner type of an array?
Example:
Let's say I already have something like this in my codebase:
export interface Cache {
events: Event[],
users: User[]
}
type CacheType = Event[] | User[];
//or maybe:
// type TypeOfProperty = T[keyof T];
// type CacheType = TypeOfProperty<Cache>;
What I want is something which would be equivalent to this:
type InnerCacheType = Event | User;
But without manually retyping it every time I add something to Cache
or CacheType
Is this possible in Typescript?