3 ms·
AFAIK typescript interfaces don't exist at runtime, so you can't validate incoming JSON with type any. Also you can't really hand a third party a typescript in
by HumanDrivenDev 9y ago
AFAIK typescript interfaces don't exist at runtime, so you can't validate incoming JSON with type any.
Also you can't really hand a third party a typescript interface and tell them to conform with that.
And finally, I would imagine a good schema could enforce more things like the length of identifiers, whether a number can be negative, etc.
- 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...