zod icon indicating copy to clipboard operation
zod copied to clipboard

fix: Fix `ZodCatch`

Open santosmarco-caribou opened this issue 2 years ago • 1 comments

This PR fixes ZodCatch.

It looks like ZodCatch was a product of a quick copy-paste from ZodDefault, which introduced some bugs to it.

  1. The output of a ZodCatch was previously defined as util.noUndefined<T["_output"]> (from ZodDefault) when it should actually be T["_output"] | <<catch value>>.
  2. The input of a ZodCatch was previously defined as T["_input"] | undefined (also from ZodDefault) when it should actually be the T["_input"] unchanged.
  3. Renamed props and methods from default to catch.

santosmarco-caribou avatar Dec 21 '22 00:12 santosmarco-caribou

Deploy Preview for guileless-rolypoly-866f8a ready!

Name Link
Latest commit e4845e00dcf96e45218cd8f1479510763bad233f
Latest deploy log https://app.netlify.com/sites/guileless-rolypoly-866f8a/deploys/63a6a0634f3f6b000805f7ab
Deploy Preview https://deploy-preview-1733--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 settings.

netlify[bot] avatar Dec 21 '22 00:12 netlify[bot]

Yikes, good catch.

I pushed a commit to fix the tests, since those weren't updated. I also got rid of the second generic on ZodCatch - the value passed into .catch() should match T['output'] exactly and there's no need for additional inference there. Good PR!

colinhacks avatar Dec 24 '22 06:12 colinhacks

Which release is this planned to be put into ?

popoleeMaster avatar Jan 24 '23 11:01 popoleeMaster

Landed in [email protected]

colinhacks avatar Feb 08 '23 10:02 colinhacks