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

Use satisfies instead of type annotation #82

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mattrossman
Copy link

Description

Currently the object schemas look like const Schema: z.ZodType<> = ...;

As mentioned in #64 this causes properties to go missing. However, that PR suggests removing this annotation which @omar-dulaimi states causes problems with tRPC.

This PR uses the satisfies operator to provide the type information instead. I am using this approach in a tRPC project without an issue.

References

Compare the difference in explicit type annotation vs satisfies here:

image

https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgLzgXzgMyhEcDkyEAJvgNxxwD0VcMAnmAKYDOAXHAMwB0ATAIzcALACgRTAB6RYdRkzgBVFkygBhKEwCGMeQF5EIysGIcWMKMAB2Ac0NxLmkEwD8p81dtoxAYwiWzispqGtpMAMreABZMIJoAWiQAKnIcyNwJxMnMADxKKupaOgB8cPppEABGAFZM3jAAFAh2xqncZhY29QCUADR2Dk6t7R7d3BBgMMB+mgA23X1oXWJ5wYXhUTHxSXJjIMAwdpRHxycnNHAAes4+fgErBaER0bFh2sAsmMCspShj1bUNJpGEy-YadXr9RxMIbucFjCZTBxzCGLOAsN4fL4sX4ZLJMXJBB7FZaEkI6J6bV6TTGsXb7Q6nRmM85XERAA

@mattrossman mattrossman marked this pull request as draft May 5, 2023 15:53
@mattrossman
Copy link
Author

Related: colinhacks/zod#2403

@omar-dulaimi
Copy link
Owner

Hey, thanks for your work on this. Hope we find a solution soon,

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.

2 participants