Hacker News new | past | comments | ask | show | jobs | submit login

> I completely understand TypeScript, Zod not so much

Different tools. I only use TS but once you add external data to the mix you cannot escape `any` and `unknown` — so what you do is use `as`. Congrats, your types are now useless.

Zod would close that gap as it enforces types on external resources (e.g. `fetch` or `readFile`)




That's not necessarily true.

You can write type assertion functions that validate the input is a given shape.

In theory, you'd use these type assertion methods at any API boundaries a single time for external inputs/outputs in a "Parse, Don't Validate" approach to cover your bases.


Soooo exactly what Zod is doing?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: