zod
zod copied to clipboard
Recursive type with promise - Recursive property returns a unresolved promise
Hello all,
I just came across a case that confuses me.
The APIs response has a recursive structure. The object returned from the function call to the API is a promise.
I'm somewhat following the docs having an interface and then calling
[...]z.ZodType<Something> =
z.lazy(() =>
z.promise(
z.object({[...]
The non-recursive attributes are resolved, but the attributes of the recursive property are now a promise (even though they are contained in the object I get back). Somehow I seem to be missing how I should explain that the outer object is a promise, not every recursive element in it.
Would appreciate it if someone could jump in with an explanation 👍