When I try to pass a conatant instead of in-place values for the field below, I get a type error, but if I use an in-place value, everything works fine
import * as z from "zod";
const data = ["1", "2"];
// this way works fine
/*
age: z.enum<any, [string, ...string[]]>(["1", "2"])
*/
const schema = z.object({
name: z.number(),
age: z.enum<any, [string, ...string[]]>(data) // error here
});
and here is how z.enum type look
declare function createZodEnum<U extends string, T extends Readonly<[U, ...U[]]>>(values: T): ZodEnum<Writeable<T>>;