Perhaps I should have chosen a better example, argument order is just an illustration.
In 1998 the Mars Climate Orbiter[0] failed because of a fairly simple software error - an imperial value was treated as metric causing the spacecraft to calculate an invalid trajectory and burn up on entry to Mars orbit. This bug was not detected in testing.
With opaque types this could never have happened, it would have produced a compiler error long before the bug ever made it into production. They eliminate an entire category of bugs.
I have come across a need for this in typescript and have used similar approaches as the author. Maybe this is a bad outlook of mine, but I am tending more and more to trusting my tooling over some of my fellow developers.
In 1998 the Mars Climate Orbiter[0] failed because of a fairly simple software error - an imperial value was treated as metric causing the spacecraft to calculate an invalid trajectory and burn up on entry to Mars orbit. This bug was not detected in testing.
With opaque types this could never have happened, it would have produced a compiler error long before the bug ever made it into production. They eliminate an entire category of bugs.
[0] https://en.wikipedia.org/wiki/Mars_Climate_Orbiter