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

Use io-ts: https://github.com/gcanti/io-ts

You define a decoder schema, and then the resulting TS type gets automatically derived for you. You can then run data through the decoder, it will err if there's a mismatch, or return a value of the inferred type otherwise.



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

Search: