Is there a way to create a structure that can handle recursive relationships like the one described below? I am looking to limit the types of values that can be added to a general container to either primitive data types or other containers. Due to limitations with interfaces not being able to extend from types and types not being able to reference themselves, it is uncertain whether this can be achieved:
type Primitive = string | boolean | number | null;
type Value = Primitive | MyContainer<Value>; // <-- error here
interface MyContainer<T extends Value> {
get(key: string): T;
set(key: string, value: T): void;
}