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

Use something like https://github.com/lbovet/typson to generate a JSON schema for your interfaces, then use a JSON schema validator before casting the API response to your interface.

I haven't touched TS since ~1.3, but this was all working well back then at least.



Typson hasn't been updated for a while, we use https://github.com/YousefED/typescript-json-schema which works with recent typescript coupled with https://github.com/mafintosh/is-my-json-valid




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

Search: