4 ms·
Use something like https://github.com/lbovet/typson https://github.com/lbovet/typson to generate a JSON schema for your interfaces, then use a JSON schema valid
by Nemo157 9y ago
Use something like https://github.com/lbovet/typson 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.
- sceutre 9y agoTypson hasn't been updated for a while, we use https://github.com/YousefED/typescript-json-schema https://github.com/YousefED/typescript-json-schema which works with recent typescript coupled with https://github.com/mafintosh/is-my-json-valid https://github.com/mafintosh/is-my-json-valid