Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect array types #22

Open
bartoszkrawczyk2 opened this issue Jan 9, 2024 · 2 comments
Open

Incorrect array types #22

bartoszkrawczyk2 opened this issue Jan 9, 2024 · 2 comments

Comments

@bartoszkrawczyk2
Copy link

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
Copy link
Owner

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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants