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

Extend z.discriminatedUnion to support intersections, unions, and discriminated unions of objects as options #3956

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

spinda
Copy link

@spinda spinda commented Jan 23, 2025

This extends z.discriminatedUnion to support not just objects but intersections, unions, and discriminated unions of objects, and nested combinations thereof, so long as the discriminator is always present on the final object value.

The globs in the `prettier:*` scripts in `package.json` need to be
quoted to ensure that the globs are evaluated by Prettier, rather than
the shell. Before, the globs only matched files in _subdirectories_ of
`src/` and `deno/lib/`, and not top-level files in those directories.
This is demonstrated by `deno/lib/types.ts` having incorrect formatting.

Also fix globbing errors in the `lint-staged` config and include the
deno files there as well for consistency.
Copy link

netlify bot commented Jan 23, 2025

Deploy Preview for guileless-rolypoly-866f8a ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit a87696a
🔍 Latest deploy log https://app.netlify.com/sites/guileless-rolypoly-866f8a/deploys/6791e26387bcf3000814a21e
😎 Deploy Preview https://deploy-preview-3956--guileless-rolypoly-866f8a.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@spinda spinda changed the title Advanced discriminated unions Extend z.discriminatedUnion to support intersections, unions, and discriminated unions of objects as options Jan 23, 2025
@spinda spinda marked this pull request as draft January 23, 2025 05:49
This extends `z.discriminatedUnion` to support not just objects but
intersections, unions, and discriminated unions of objects, and nested
combinations thereof, so long as the discriminator is always present on
the final object value.
@spinda spinda force-pushed the advanced-discriminated-unions branch from de72d0a to a87696a Compare January 23, 2025 06:32
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