Hacker News new | past | comments | ask | show | jobs | submit login

I've been programming JS for 13 years (professionally, and some more as a hobby) and I'm pretty aware of its warts. And as a firm believer of TDD, most of my code is pretty well tested.

Unit tests have similar advantages to types: they catch errors early and let you refactor your code with confidence.

But unit tests go even further, because they test the _correctness_ of the returned value, not just its type.

And a massive turnoff for me is that the types are compile-time only.

So you see, if your code is tested, and the types are just partial static checks; I feel like it's just not worth it.

I enjoy using types in other languages, for example it feels nice to add type hinting to old PHP codebases. But in PHP, types are much simpler (less work) and more effective.

If they added optional run-time instrumentation like "spec" in Clojure, I would definitely use TS. But for now, I'm out.




You should be testing regardless of the strength of your type system.

But testing with a weak type system isn't going to give you anywhere near the guarantees you'd get from a well-designed type system in addition to testing: https://kevinmahoney.co.uk/articles/tests-vs-types/




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: