Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Interesting.. I'd rather write typescript types than Zod schemas. I haven't used JSON schema, but going TS to Zod was straightforward and really pleasant


Typescript can't understand types as objects, but it can understand objects as types (using typeof). So starting with objects and generating types is more natural.

Also if you start with objects you can express runtime conditions that are not possible with types, for example maximum sizes.

Zod is quite a bit more general than JSON schema because it can express transformations not just validations.


That way does not give you runtime validation of input.

(Or, requires an extra build step to generate that. It's beyond Typescript itself.)




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

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

Search: