DEV Community

Discussion on: I used to think TypeScript is a waste of time. Now I changed my mind.

Collapse
 
rcmedeiros profile image
Rafael Medeiros

Turning from Java to Javascript in 2016, I felt extremely naked without type notations, as if leaving home without my pants. It looked like some array would rebel and leak into a number at any moment and I would try to divide it by some other NaN and catastrophy was inevitable. But I was wrong, that's why we test our code. And my services from that time are stable in production to this day.

But I never overcame that insecurity and I did have an Angular project to maintain so I was used to Typescript, and after one year I decided to shift every backend code too. And I'm the architect of a team so I'm responsible for everybody's code, and gradually applied some very strict Tslint rules too.

I'm in a corporate yes, but only because what used to be a start-up back then grew up. Unreasonable deadlines are the only deadlines I know.

There are many reasons to take different people through different paths towards the same goal, and my experience was very positive in ways pure JS isn't suppose to deliver.

  • Coding was actually faster if you stretch coverage to 90% min, because intelliSense predicted much more autocompletions, made possible by Type Info;
  • Junior developers likelyhood to write spaghetti code diminished. Rejections now are mostly for layer violations;
  • Testing also took advantage of it, because there were much more assertions that left runtime and didn't have to be written;
  • Dependency inversion FTW. I know pure JS can somewhat do it too but there's nothing like surrounding every layer with interfaces and constantly upgrading low level code without touching the rest of the build.

I still write quick js files to test a theory or even a PoC, but TS became my default.