I want to define a variable Mapthat should contain either a primitive value (string | number | boolean), or another of Mapthe same type.
I tried to do this:
type Primitive = string | number | boolean;
type SafeNestedMap = Map<string, Primitive | SafeNestedMap>;
let states: SafeNestedMap = new Map<string, SafeNestedMap>();
however, the compiler complains:
TS2456: Type alias 'SafeNestedMap' circularly references itself.
How can I correctly declare this recursive type?
source
share