You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey, I'm trying to define my schemas, everything was fine until I needed to add recursion. I'm having issues with both the date and enum fields. Here's and example code:
But when I compile I get error, if I remove transform() then it works.
TS2322: Type 'ZodObject<extendShape<{ name: ZodString; date: ZodEffects<ZodNumber, Date, number>; }, { subcategories: ZodLazy<ZodArray<ZodType<Category, ZodTypeDef, Category>, "many">>; }>, "strip", ZodTypeAny, { ...; }, { ...; }>' is not assignable to type 'ZodType<Category, ZodTypeDef, Category>'.
Types of property '_input' are incompatible.
Type '{ date: number; name: string; subcategories: Category[]; }' is not assignable to type 'Category'.
Type '{ date: number; name: string; subcategories: Category[]; }' is not assignable to type '{ date: Date; name: string; }'.
Types of property 'date' are incompatible.
Type 'number' is not assignable to type 'Date'.
TS2322: Type 'ZodObject<extendShape<{ name: ZodString; enum: ZodCatch<ZodNativeEnum<{ readonly RED: "red"; readonly GREEN: "green"; readonly UNKNOWN: "unknown"; }>>; }, { subcategories: ZodLazy<...>; }>, "strip", ZodTypeAny, { ...; }, { ...; }>' is not assignable to type 'ZodType<Category, ZodTypeDef, Category>'.
Types of property '_input' are incompatible.
Type '{ name: string; subcategories: Category[]; enum?: unknown; }' is not assignable to type 'Category'.
Type '{ name: string; subcategories: Category[]; enum?: unknown; }' is not assignable to type '{ name: string; enum: "unknown" | "red" | "green"; }'.
Types of property 'enum' are incompatible.
Type 'unknown' is not assignable to type '"unknown" | "red" | "green"'.
The text was updated successfully, but these errors were encountered:
You assigned the wrong type to the categorySchema. In general, avoid assigning type yourself. Good typescript looks like a javascript. Let TS do its job.
Did you want to achieve categorySchema to have other nested categorySchemas and so on?
Hey, I'm trying to define my schemas, everything was fine until I needed to add recursion. I'm having issues with both the date and enum fields. Here's and example code:
But when I compile I get error, if I remove transform() then it works.
The text was updated successfully, but these errors were encountered: