by pontilanda · 3y ago · 0 comments
If I change a signature, tests fail. If I pass junk data, tests fail. It's like invisible live tests and people forget this.
As in the other recent discussion, yeah, you can live without tests and you can live in JS-land. Whether it's worth it it depends on you. TS and traditional testing lets me ship updates without even opening node or the browser.
Types are not the same as tests at all, tests are much better at giving you a glimpse of what the code even does.
For clarity, I'll define a static typing opponent as somebody who believes that the return on investment for static typing is negative.
Types do that, they tell you the expected input and expected output. No type nor test is all-encompassing of course, but it gives at least some information.
No test will guarantee that a function will never return a number. Types, if valid and without prototypal shenanigans, can.