Use satisfies instead of type annotation #82
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgLzgXzgMyhEcDkyEAJvgNxxwD0VcMAnmAKYDOAXHAMwB0ATAIzcALACgRTAB6RYdRkzgBVFkygBhKEwCGMeQF5EIysGIcWMKMAB2Ac0NxLmkEwD8p81dtoxAYwiWzispqGtpMAMreABZMIJoAWiQAKnIcyNwJxMnMADxKKupaOgB8cPppEABGAFZM3jAAFAh2xqncZhY29QCUADR2Dk6t7R7d3BBgMMB+mgA23X1oXWJ5wYXhUTHxSXJjIMAwdpRHxycnNHAAes4+fgErBaER0bFh2sAsmMCspShj1bUNJpGEy-YadXr9RxMIbucFjCZTBxzCGLOAsN4fL4sX4ZLJMXJBB7FZaEkI6J6bV6TTGsXb7Q6nRmM85XERAA