DEV Community

loading...

Discussion on: A Simple Argument For Typescript

Collapse
baso53 profile image
Sebastijan Grabar • Edited

TypeScript really does catch these kinds of bugs. To whoever says that it isn't that often that you find yourself in this situation, I don't think you are looking at the whole picture. Maybe when you're writing new code, yeah, you don't do these kinds of errors that often, but consider refactoring.

Rename a property name and your IDE doesn't refactor the name in all the places. TypeScript will tell you that a property name isn't correct somewhere else in the code and in turn, won't compile (okay, yeah, maybe it will if you have it configured like that, but it will at least print out the error for you). This is the kind of situation where TypeScript saves my ass and my time. I was literally in this situation TODAY.

But maybe even more importantly, where TypeScript really shines, is when it provides you the valuable information about types in a project you've never seen before in your life. Of course it's okay when you're working on a project and know the domain and know exactly what type each property is going to be, but for f*cks sake, you aren't the only person in the world who will work on this project. Someone will come after you eventually, and to THEM, TypeScript is a godsend. This is especially true for open-source projects. If you want to make a small change, you can do that in literally a few minutes, without TypeScript you would first be digging through tons of API documentation just to know what the hell is going on.

TypeScript is underrated.

Forem Open with the Forem app