Skip to content

fix: use numerical enums when creating zod schema#108

Merged
mnahkies merged 1 commit into
mainfrom
mn/fix/numeric-enum-schemas
Nov 12, 2023
Merged

fix: use numerical enums when creating zod schema#108
mnahkies merged 1 commit into
mainfrom
mn/fix/numeric-enum-schemas

Conversation

@mnahkies
Copy link
Copy Markdown
Owner

stop ignoring the enum property on number schemas when generating zod schemas,
which avoids number is not assignable to 301 | 302 | 303 type errors.

uses a z.union / z.literal workaround as z.enum is not compatible with numbers (see also colinhacks/zod#2686 (comment))

Comment thread package.json
"eslint-plugin-jest": "^27.6.0",
"husky": "^8.0.3",
"jest": "^29.7.0",
"jest": "^30.0.0-alpha.1",
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently inline snapshots aren't compatible with prettier@3 before this version 🤷 (jestjs/jest#14305 (comment))

@mnahkies mnahkies force-pushed the mn/fix/numeric-enum-schemas branch from b9dc22d to ce43206 Compare November 12, 2023 12:17
@mnahkies mnahkies enabled auto-merge (squash) November 12, 2023 12:18
@mnahkies mnahkies merged commit 7564c10 into main Nov 12, 2023
@mnahkies mnahkies deleted the mn/fix/numeric-enum-schemas branch November 12, 2023 12:20
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 this pull request may close these issues.

1 participant