Type hints made for recursive types z.lazy( ... ) make all properties optional. I made a minimal reproducible example repo with the example of recursive types given in the documentation and this error is present.
Error Output
Type 'ZodObject<extendShape<{ name: ZodString; }, { subcategories: ZodLazy<ZodArray<ZodType<Category, ZodTypeDef, Category>, "many">>; }>, "strip", ZodTypeAny, { ...; }, { ...; }>' is not assignable to type 'ZodType<Category, ZodTypeDef, Category>'.
Types of property '_type' are incompatible.
Type '{ name?: string; subcategories?: Category[]; }' is not assignable to type 'Category'.
Type '{ name?: string; subcategories?: Category[]; }' is not assignable to type '{ subcategories: Category[]; }'.
Property 'subcategories' is optional in type '{ name?: string; subcategories?: Category[]; }' but required in type '{ subcategories: Category[]; }'. ts(2322)
Issue
Type hints made for recursive types
z.lazy( ... )
make all properties optional. I made a minimal reproducible example repo with the example of recursive types given in the documentation and this error is present.Error Output
tsconfig.json
Example
https://github.com/alligatorjazz/recursive-error