Typing offers guarantees. You can guarantee that your function will receive the right inputs, and produce the right outputs. Even soft typing enforced by an IDE is beneficial in that sense.
I have refactored a large, central chunk of JavaScript code back at HERE. I found and fixed several bugs related to typing as I went along.
A lot of code passed server responses or a subset of them as-is, so I had to read API documentation to understand the inputs of some deep parts of the frontend code. This is why I favour explicitly encapsulating server responses in a data class.
In addition to typing, I favour microtypes and enums. Those go further to prevent unexpected application states. Assert statements are a last barrier against unmet expectations that could break things.
If you want to build reliable software, you must be strict about the inputs you accept. Don't let sloppy inputs propagate.
I have refactored a large, central chunk of JavaScript code back at HERE. I found and fixed several bugs related to typing as I went along.
A lot of code passed server responses or a subset of them as-is, so I had to read API documentation to understand the inputs of some deep parts of the frontend code. This is why I favour explicitly encapsulating server responses in a data class.
In addition to typing, I favour microtypes and enums. Those go further to prevent unexpected application states. Assert statements are a last barrier against unmet expectations that could break things.
If you want to build reliable software, you must be strict about the inputs you accept. Don't let sloppy inputs propagate.