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

The "-1" and "0" literals do not work #101

Closed
araera111 opened this issue Nov 21, 2022 · 0 comments · Fixed by #132
Closed

The "-1" and "0" literals do not work #101

araera111 opened this issue Nov 21, 2022 · 0 comments · Fixed by #132

Comments

@araera111
Copy link

Bug description

I used ts-to-zod.
Errors occurred when used for types containing "-1" and "0" literals

Input

export interface bugType {
	flag_a: -1 | 0;
}

Expected output

export const bugTypeSchema = z.object({
  flag_a: z.union([z.literal(-1), z.literal(0)])
});

Actual output

export const bugTypeSchema = z.object({
  flag_a: z.union([z.-1(), z.literal(0)])
}); // error

Versions

  • Typescript: v4.8.3
  • Zod: v3.19.1
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

Successfully merging a pull request may close this issue.

1 participant