3 ms·
> AFAIK typescript interfaces don't exist at runtime, so you can't validate incoming JSON with type any. That's mostly true, but some projects exist that allow
by zbentley 9y ago
> AFAIK typescript interfaces don't exist at runtime, so you can't validate incoming JSON with type any.
That's mostly true, but some projects exist that allow a subset of interfaces to be used at runtime:
- https://github.com/gcanti/io-ts https://github.com/gcanti/io-ts
- https://github.com/fabiandev/ts-runtime https://github.com/fabiandev/ts-runtime
- https://github.com/codemix/flow-runtime https://github.com/codemix/flow-runtime
- Or just manual assertions: https://gist.github.com/JohnWeisz/beb7b4dadc512be30ce6c7c1e4c7e652 https://gist.github.com/JohnWeisz/beb7b4dadc512be30ce6c7c1e4...