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

> Is this something like clojure.spec by for TypeScript so you can do runtime validation of data instead of compile-time

not really "instead", more like "in addition to". Even if your code compiles, if you are receiving data, e.g., via API, then you need to check that it actually conforms to the type/schema you expect. What is run is JS, so it, sadly, won't just crash/error if an object that is supposed to be of `type Cat = {name: string, ownerId: number}` lacks an `ownerId` at runtime.

Have you used Pydantic in Python? It's like that, but feels worse, IMO lol. I say this because Pydantic fits into writing Python code much more naturally than writing Zod stuff fits into writing TypeScript, IMO.






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

Search: