Hacker News new | past | comments | ask | show | jobs | submit login
Io-to: both static and dynamic type checking for JSON API data in TypeScript (olioapps.com)
30 points by fanf2 on April 19, 2018 | hide | past | favorite | 5 comments



An alternative I'm a fan of: using 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.


This is nice, but I'd prefer to use mobx-state-tree to reason about models and the logic around them. The ability to use middleware to implement things like undo [1], is really powerful.

[1] https://github.com/mobxjs/mobx-state-tree/tree/master/packag...


Looks nice; I use “decoders” with Flow for this use case myself. Can even avoid doubling up in type/parsing definitions by deriving the type of the result via inference, from the decoder. Excited to play with this for my TypeScript projects.


This is awesome. I was looking for this a few weeks ago and found a library I don’t love. This feels right for Typescript and I’m going to add it to a big project like immediately. Great job to the authors!


Nice to see another feature of TypeScript that PureScript and Elm had for years. I will certainly use it tomorrow! (Unless I use typescript-json-schema, which is awesome too!)




Consider applying for YC's Summer 2025 batch! Applications are open till May 13

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

Search: