News for hackers. Stuff that matters.
Re:Ask HN: Do you use JSON Schema? Help us shape its future ... by pcthrowaway on Tuesday January 31, 2023 @04:24AM (#34593083)
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
Re:Ask HN: Do you use JSON Schema? Help us shape its future ... by zarzavat on Tuesday January 31, 2023 @05:02AM (#34593330)
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.

Re:Ask HN: Do you use JSON Schema? Help us shape its future ... by yencabulator on Wednesday February 01, 2023 @12:04PM (#34613566)
That way does not give you runtime validation of input.

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