3 ms·
> code may typecheck in the browser you tested, but it has to run in other browsers which have differences in their APIs. If you are referring to an second API
by jnbiche 9y ago
> code may typecheck in the browser you tested, but it has to run in other browsers which have differences in their APIs.
If you are referring to an second API that is differently typed, what happens if you do use a dynamically-typed language there? Then you're running under the assumption of one type when you actually are getting another? Your program is in an inconsistent state. Very often, at least in languages like JavaScript and Python, that means that very strange and obscure bugs will eventually start popping up.
Unfortunately, the same can happen with static typed languages receiving data from an external API unless you're doing runtime checks of external APIs (which is often a good idea).
So the ideal thing to do is to runtime validate external APIs and account for any differences that turn up in the APIs. Ignoring the differences in any language is very often the start of downstream bugs, not a graceful way of handling the problem.