Refactor zodToEffect for improved type inference and add tests#1559
Conversation
🦋 Changeset detectedLatest commit: d5d3880 The changes in this PR will be included in the next version bump. This PR includes changesets to release 12 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (13)
📝 WalkthroughWalkthroughThe PR updates ChangesZod conversion typing
Automation reference updates
Playground site configuration
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Allure Test Report for this PR:✅ Allure Report | History |
create-studiocms
effectify
studiocms
@studiocms/auth0
@studiocms/blog
@studiocms/cloudinary-image-service
@studiocms/devapps
@studiocms/discord
@studiocms/github
@studiocms/google
@studiocms/html
@studiocms/markdoc
@studiocms/markdown-remark
@studiocms/md
@studiocms/mdx
@studiocms/s3-storage
@studiocms/upgrade
@studiocms/wysiwyg
@withstudiocms/api-spec
@withstudiocms/auth-kit
@withstudiocms/cli-kit
@withstudiocms/component-registry
@withstudiocms/config-utils
@withstudiocms/effect
@withstudiocms/internal_helpers
@withstudiocms/kysely
@withstudiocms/sdk
@withstudiocms/template-lang
commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This pull request improves the type inference and correctness of the
zodToEffectfunction, which converts Zod schemas to Effect schemas. It introduces a new type-safe approach for mapping Zod schemas to Effect schemas, ensuring that the input and output types are preserved accurately. Additionally, comprehensive tests are added to verify the correctness of the type mappings for complex and nested schemas.Type inference and API improvements:
zodToEffectfunction inzod.tsto use a new type aliasEffectSchemaFromZod, ensuring that the resulting Effect schema preserves the input and output types of the original Zod schema. The function signature is now generic and type-safe, and the implementation usesSchema.Schema.AnyNoContextto avoid previous type mangling issues.Testing and validation:
zod.types.test.tsthat verifieszodToEffectproduces Effect schemas with the correct input and output types for both complex ("kitchen-sink") and nested object schemas, usingexpectTypeOfassertions for type equality.Summary by CodeRabbit
New Features
Tests
Chores