0

Essentially I want to achieve this:

type Foo = ({bar: string} & Record<string, Foo>) | Foo[]

I keep running into either circular reference drawback for type or
An interface can only extend an object type or intersection of object types with statically known members for interface, with something like this:

type Atom = { bar: string } & Record<string, Foo>
type ArrayOrRecord = Atom | Array<Atom>
interface Foo extends ArrayOrRecord {}

There was a similar question raised here Recursive array type typescript, but the difference is that in my case Atom has recursive properties as well.

1 Answer 1

0

Just expand the Record definition:

type Foo = ({bar: string} & { [K in string] : Foo }) | Foo[]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.