zod icon indicating copy to clipboard operation
zod copied to clipboard

Update documentation to include `strictNullChecks` as required

Open artokun opened this issue 1 year ago • 5 comments

This PR is intended to help other engineers avoid the same mistake I made by having strict set to true but not strictNullChecks which led to very frustrating / confusing functionality when dealing with static typechecking

artokun avatar Sep 29 '22 08:09 artokun

Deploy Preview for guileless-rolypoly-866f8a ready!

Built without sensitive environment variables

Name Link
Latest commit 129d7359fdd3ecb8a565a0a87e3a02878fa1847a
Latest deploy log https://app.netlify.com/sites/guileless-rolypoly-866f8a/deploys/6335547c55c59500097074de
Deploy Preview https://deploy-preview-1438--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 Sep 29 '22 08:09 netlify[bot]

FWIW, strict implies strictNullChecks, so I think our stance is still "enable strict" since we rely on the most strict behavior possible. The fact that you can opt out of certain parts of the strict-mode is understandable but unfortunate, and this is a speed bump that people run into, so I'm 👍 for this change for practicality,

scotttrinh avatar Sep 29 '22 19:09 scotttrinh

For the sake of future-proofing Zod, I think we should assume that strict mode is enabled, and none of its individual components have been disabled. I'm not sure if Zod compiles if only strictNullChecks istrue but none of the other strict mode checks. Strict mode also may encompass other flags later so it's easiest to have a blanket policy of "use strict mode".

colinhacks avatar Sep 30 '22 16:09 colinhacks

@colinhacks

For the sake of future-proofing Zod, I think we should assume that strict mode is enabled, and none of its individual components have been disabled.

This is my strong feeling as well. It is a common pitfall (probably 40% of all questions and issues are exactly this issue) and sometimes people extend base configurations that do not make it obvious that there is something wrong. Maybe the better approach here is to add a troubleshooting or FAQ section to address "Why is my object schema partial?"

scotttrinh avatar Oct 05 '22 01:10 scotttrinh