I will not go into the specifics of why I disagree with that sentiment. Much has already been written about the advantages of type safety by people that are both more eloquent and more knowledgeable in the subject than me. My own little stories of how type strictness saved me time and chagrin are but a little drop in the ocean of other similar tales out there.
Instead, I want to propose a different way to look at the problem.
TypeScript is a bicycle.
For a second, imagine bicycles were invented today and we were to compare them to the natural act of walking.
Using a bicycle forces you to act in a certain (some would say, more strict) way. Suddenly, you cannot just hop over a trunk; you need to dismount, and, carrying the bicycle on your arms, hop over it. Stairs are also complicated, needing similar if not greater effort in a bicycle. If you donâ€™t have a lot of storage space in your home, a bicycle does not help either; it is hard to store, what with its odd frame and the inability to stand up straight unassisted. Also, the skill of riding a bicycle has a somewhat scary learning curve; youâ€™re likely to fall a few times, or worse, to look like a fool, before youâ€™re able to ride them efficiently.
The reality is that under most conditions, riding a bicycle will beat walking. You will get to your destination faster, and with less effort. You may not even need to hop over the trunk, or take the stairs at some pointsâ€Šâ€”â€Šgoing around it in your bicycle will likely be faster. Some problems will never go away: you will need to store your bicycle somewhere, and some amount of maintenance is necessary. But that doesnâ€™t change the fact that if you need to get from point A to point B with the least amount of effort, all things considered, a bicycle is likely to be the most efficient way.
When TypeScript (and, truth be told, other similar transpilers or checkers) ask you to declare the type of a variable, or when it does type inference, itâ€™s not really restricting what you can do. You can, after all, still declare things as being of any type, or just outright leave it undeclared. It is not slowing you down; not in the long run. It is, instead, making sure you go faster by forcing you to think on where you want to go, and then not allowing your code to stray from the path too much.
If youâ€™re working with a dynamically typed language, the next time you run into a small misspelling error that took you some time to track and fix, or the next time you have to compile and run your code just to see if your references are right, or the next time you write a test to check for something trivial, think about how much time you could have saved with a transpiler that caught those before the code was ranâ€Šâ€”â€Šor better yet, while you were still writing the code, right from your editorâ€Šâ€”â€Šwith 100% accuracy.
Thatâ€™s the bicycle youâ€™re refusing to learn how to ride.