I am striving to achieve the following:
type Foo = ({bar: string} & Record<string, Foo>) | Foo[]
However, I keep encountering issues such as circular references in type
or
the constraint that
An interface can only extend an object type or intersection of object types with statically known members
when using interface
, resulting in code like this:
type Atom = { bar: string } & Record<string, Foo>
type ArrayOrRecord = Atom | Array<Atom>
interface Foo extends ArrayOrRecord {}
A similar question was discussed here Recursive array type typescript, but my situation differs in that Atom contains recursive properties.