3 ms·
Agreed, the benefits of type safety are often thrown around but this is sort of what type safety looks like. Yes, as the author says it makes things "annoying t
by Scriptor 11y ago
Agreed, the benefits of type safety are often thrown around but this is sort of what type safety looks like. Yes, as the author says it makes things "annoying to develop". This is because the developer now has to read the docs and be aware of this invariant for the particular component they're using. They'll go, "Damn, guess I can't use a list here," and fix their code.
However, let's say later down the line a new engineer comes in and is tasked with a bug fix. If they're using Cycle.js and see an array, they might think, "Oh, I can easily solve this by adding another element to this one-element array." Without any invariants they'll run into subtler bugs and errors trying to figure out what went wrong.
But with the invariant, if they tried to jam an array there they would immediately get an error and know what's wrong.
This isn't something that will crop up in a simple one-day project like the author was creating with his coworker. It's instead a great example of how a little annoyance can make future maintainability way easier.