Types vs tests is a false dichotomy


Types vs tests is a false dichotomy. You can and should use both.

But here’s why some teams favor types over tests:

✅ Types provide real-time inline feedback. Tests don’t. Types are tests with better ergonomics.

✅ Types eliminate the need for writing many basic, time-consuming, tedious tests. So types provide basic safety more quickly.

✅ Types assure all code fits together. Tests don’t unless 100% coverage is achieved and maintained, which is both difficult and uncommon.

✅ It’s easier to use types effectively. It’s easy to spot missing types. It’s hard to spot bad tests.

✅ Linters and compilers reliability catch missing types. But missing/bad tests are hard to spot because code coverage metrics are easy to game.

✅ It’s easier to find developers who who are effective with types than tests. Writing effective, fast, stable, and comprehensive tests is hard.

✅ Types tend to change less often, and one can “lean on the compiler” when they do, so they’re easier to change. Tests often flake and require ongoing, time-consuming changes as logic shifts.

✅ Types enable rich autocomplete. Tests don’t.

View original on X