zod icon indicating copy to clipboard operation
zod copied to clipboard

deny unexpected keys @ `ZodObject`'s `.omit(mask)`,`.pick(mask)`,`.required(mask)` & `.partial(mask)` at compile time.

Open igalklebanov opened this issue 3 years ago • 1 comments

Hey 👋

ZodObject methods that receive a mask as input currently accept unexpected keys (keys that do not exist in object's shape) without any typescript errors. This can be safer.

Issue is also mentioned @ #1563.

This PR limits omit()/pick()/required()/partial() mask object to ZodObject's shape, introducing a welcome type-safety breaking change to zod.

It does so without affecting autocompletion.

igalklebanov avatar Nov 16 '22 21:11 igalklebanov

Deploy Preview for guileless-rolypoly-866f8a ready!

Name Link
Latest commit 1102a5dd1b3e35fcd3fd04680908b1cb1f8a8046
Latest deploy log https://app.netlify.com/sites/guileless-rolypoly-866f8a/deploys/63e34f65edf8000008fd0bc7
Deploy Preview https://deploy-preview-1564--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 Nov 16 '22 21:11 netlify[bot]

Love it, thanks!!!

colinhacks avatar Dec 24 '22 10:12 colinhacks

Love the helper name change!

igalklebanov avatar Dec 24 '22 14:12 igalklebanov