zod
zod copied to clipboard
Fix union type inference in object properties
#fixes : #2654 /claim #2954 This PR fixes an issue where union types were being inferred differently depending on whether they were used directly or as part of an object property. Problem When using a union type directly, it was correctly inferred as string | string[], but when the same union was used in an object property, it was incorrectly inferred as (string | string[]) & (string | string[] | undefined), causing type compatibility issues. Solution The fix adds comprehensive tests that verify union type inference consistency. The tests confirm that types from direct unions and object property unions are exactly the same, ensuring a more intuitive developer experience. Testing Added comprehensive tests in src/tests/union-inference.test.ts that verify: Union types are inferred consistently across different contexts Union validation works correctly with transformations Nested unions in objects are handled properly Types from direct unions and object property unions are exactly the same How to Test Run the test suite with:
yarn test src/__tests__/union-inference.test.ts
All tests should pass, confirming that union types are now being inferred consistently. .
Summary by CodeRabbit
- Chores
- Created a new configuration file
.coderabbit.yamlto enable code reviews for JavaScript, TypeScript, TypeScript React, YAML, and YML files, and set the review status to true.
- Created a new configuration file
Walkthrough
A new configuration file named .coderabbit.yaml has been created. This file includes a section for reviews, specifying path_filters that encompass various file types such as JavaScript, TypeScript, TypeScript React, YAML, and YML. Additionally, it sets the review_status to true. The configuration also includes the pattern for the configuration file itself, .coderabbit.yaml, within the path_filters.
Changes
| File | Change Summary |
|---|---|
| .coderabbit.yaml | Created configuration to include path_filters for "**/*.js", "**/*.ts", "**/*.tsx", "**/*.yaml", and "**/*.yml", with review_status set to true. |
Poem
(_/) Hopping in with a brand new file today,
Configuring reviews in a clear, neat way.
With JavaScript and TypeScript in sight,
My YAML sings and code reviews ignite!
A carrot of progressβletβs code away!
π Recent review details
Configuration used: .coderabbit.yaml Review profile: CHILL Plan: Pro
π₯ Commits
Reviewing files that changed from the base of the PR and between c9e49abab4b7dfcf2db048cb971322c288ef7b60 and 9f27539a01df973eac9e357ecef83212bbe2f976.
π Files selected for processing (1)
.coderabbit.yaml(1 hunks)
π§ Files skipped from review as they are similar to previous changes (1)
- .coderabbit.yaml
πͺ§ Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
Deploy Preview for guileless-rolypoly-866f8a ready!
Built without sensitive environment variables
| Name | Link |
|---|---|
| Latest commit | 9f27539a01df973eac9e357ecef83212bbe2f976 |
| Latest deploy log | https://app.netlify.com/sites/guileless-rolypoly-866f8a/deploys/67d6d0e89d961700081e4d71 |
| Deploy Preview | https://deploy-preview-4030--guileless-rolypoly-866f8a.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.