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
If I have a type with an optional array of items, the result in the Zod schema is not marked optional(). A validation error is generated:
✖ Validating generated types
› Error: 'A' is not compatible with 'aSchema':
› Argument of type 'A' is not assignable to parameter of type '{ values: string[]; }'.
› Types of property 'values' are incompatible.
› Type 'string[] | undefined' is not assignable to type 'string[]'.
› Type 'undefined' is not assignable to type 'string[]'.
error Command failed with exit code 2.
Input
// typescript type or interface causing the outputexporttypeA={values?: Array<string>}
Expected output
// Generated by ts-to-zodimport{z}from"zod";exportconstaSchema=z.object({values: z.array(z.string()).optional(),});
Actual output
// Actual Zod schemas// Generated by ts-to-zodimport{z}from"zod";exportconstaSchema=z.object({values: z.array(z.string()),});
Versions
ts-to-zod: v1.0.1
Typescript: v4.2.3
Zod: v3.0.0-alpha.39
The text was updated successfully, but these errors were encountered:
Bug description
If I have a type with an optional array of items, the result in the Zod schema is not marked
optional()
. A validation error is generated:Input
Expected output
Actual output
Versions
v1.0.1
v4.2.3
v3.0.0-alpha.39
The text was updated successfully, but these errors were encountered: