raflymln / zod-key-parser

Parse your Zod schema into keys or Prisma ORM select format
https://www.npmjs.com/package/zod-key-parser
MIT License
16 stars 0 forks source link

Incorrect array types #22

Open bartoszkrawczyk2 opened 9 months ago

bartoszkrawczyk2 commented 9 months ago

If an array is present in the schema, it's key type should still be string.

Example:

const Schema = z.object({
  exampleInput: z.string().min(6, "at least 6 characters"),
  arr: z.array(z.string()),
});

const { keys } = parseZodSchema(Schema);

And when I hover to check the type arr is an array, but it's a key so it should be a string:

Zrzut ekranu 2024-01-9 o 18 32 40

Is it by design? Or is it bug?

raflymln commented 9 months ago

Hi @bartoszkrawczyk2 sorry for late reply, the actual return was "arr", but because of some typescript issue, until now i can't get rid of those, do you, maybe, know any workaround for that?

raflymln commented 9 months ago

or in another workaround, you can make the array as the array of object, like z.array({ name: z.string() })