4 ms·
> What good does it do when your code suddenly throws a fatal error at runtime because you did not respect the type specification. The good it does is it stops
by tomschlick 10y ago
> What good does it do when your code suddenly throws a fatal error at runtime because you did not respect the type specification.
The good it does is it stops your application from possibly continuing on with buggy code.
This is especially important in something like billing code. Imagine if your code was expecting an integer (bill amount) but got a string instead that via the types system evaluated to 0 or 1 instead of the real integer... In that case you might charge customers less or more than you should have and its a big deal trying to get all that fixed.
Better to just throw an error which you can see in an exception handling system like Sentry and take care of the problem.