3 ms·
An alternative I'm a fan of: using typescript-json-schema: https://github.com/YousefED/typescript-json-schema https://github.com/YousefED/typescript-json-schem
by untog 9y ago
An alternative I'm a fan of: using typescript-json-schema:
https://github.com/YousefED/typescript-json-schema https://github.com/YousefED/typescript-json-schema
To turn TypeScript interfaces into JSON schemas, then evaluating incoming JSON using whatever JSON schema validation library you want. It's a tradeoff though, as this replaces the need for "t.TypeOf" with some kind of separate build step that creates the schemas. I still prefer it though, as it allows me to use standard TS interfaces rather than any kind of custom format.