I Dislike TypeScript Because I've Never Maintained JavaScript Before
As a guy new to the field of computer science, having written my first hello world program in 2020, I've had the luxury of not dealing with the awkward phase of using JavaScript between ES5 and ES6.
I never had the opportunity to truly hate JavaScript because the initial groundwork had been made to improve and streamline the language. Syntax such as class and async/await from my viewpoint were just staples of the language that had always existed.
In my own journey I stopped using JavaScript for any major project I had in 2023. This occurred after I spent 4 hours debugging a Chrome extension I was developing. I realised all the issues I was having could have been solved by having a good linter and type checking.
Typescript is the main programming language at work, and so I spend most of my time writing it. I have grown to dislike the language as it does not provide the same programming ergonomics I had grown accustomed to from languages such as Rust and Gleam. It often feels like Typescript was just JavaScript with a linter and type checking on top.
The two major problems I have with TypeScript can be broken down into the following:
TypeScript allows me to easily to escape the type system by throwing
anyand using theaskeyword. Whenever I get lazy and need to circumvent some code to get it to compile I always use one of the tricks above.I am not a fan of exceptions and prefer returning errors as values. I never know when a function might throw an Exception and this leads me to wrapping quite a bit of code in
try/catchstatements.
These problems mainly stem from the fun I have using functional programming languages in my side projects. I often yearn for a similar experience at work. TypeScript itself is not a bad language. In fact Typescript is such a good language that I benefit from the issues it solves without noticing it. I often wonder how people maintain any large scale software in dynamically typed programming languages. Maintaining a pure JavaScript codebase sounds like a complete headache when it comes to tasks such as refactoring and debugging.
If I had started my career in 2010 and had to deal with maintaining a JavaScript codebase I would have constantly been tearing my hair out every time I had to debug a some bit of code. JavaScript with all its weird type coercion and silent undefined would've given me a stroke. The introduction of Typescript would've been a breath of fresh air. It actively would have made the progress of maintaining and debugging the codebase easier.
I have never experienced the issues that TypeScript solved and so never got a chance to appreciate for what it is. TypeScript never sought out to be the best language in world or even the most type safe. It was created to make maintaining JavaScript better and catch quite a few bugs before shipping the code. It serves it purpose well, and it does what it needs to do.