Southclaws / supervillain

Converts Go structs to Zod schemas
MIT License
76 stars 6 forks source link

Self-referential (aka Recursive) types cause an infinite loop #2

Open Southclaws opened 2 years ago

Southclaws commented 2 years ago

Simple one, just needs a lookup table of what's already been processed.

type X {
  Children []X
}

Or

type Y {
  Child X
}
type X {
  Children []Y
}

etc

Southclaws commented 2 years ago

https://github.com/colinhacks/zod#recursive-types

The code should generate like this, which means the code needs to not only generate x: z.string() for the zod structure but also x: string; for the forward interface declaration.