3 ms·
That's nowhere near "falling apart". That's just the simple fact there's no silver bullet. Someone arguing a little defensive programming is equivalently stron
by nawgz 5y ago
That's nowhere near "falling apart". That's just the simple fact there's no silver bullet.
Someone arguing a little defensive programming is equivalently strong to a type system is clearly unaware just how much work a good type system does for you. I of course agree with you: when you're fetching data that you don't know the type of, recklessly casting it to some type is going to cause issues. This is true in every language that has ever existed. It's also why tools like IO-TS[0] exist, and of course you can enforce this with JSON Schema techniques or custom validators or a million other options.
Edit: in case the ultimate point of this comment is not clear, by using a type system and some type validator on your fetches, you are able to reduce the need for defensive programming exclusively to your fetch points. Clearly, defensive programming at the fetch points was already needed, so this is why I do not agree with the claim TypeScript's value add disappears from remote fetches.
[0]: https://github.com/gcanti/io-ts https://github.com/gcanti/io-ts