Here are my schemas:
export const barSchema = z.object({
id: z.string(),
foo: z.object(fooSchema),
});
export const fooSchema = z.object({
id: z.string(),
bar: z.object(barSchema),
});
export type BarType = z.infer<typeof barSchema>;
My challenge lies with barSchema
, as it results in a TypeScript error:
'barSchema' is treated as 'any' due to lacking a type annotation and being referenced directly or indirectly in its own initializer.
I am determined to leverage the type inference feature. What steps should I take to achieve this goal and resolve the issue?