Why am I NOT a fan of TypeScript
TypeScript is slower than JS, in simple iteration, the difference is only a few percent but when it comes to more complex ones, it is quite enormous. The reason comes from TS’s structure, which is transpired to JS (plus additional coating). Check efficiency here!
Personally, I think most important is the efficiency of the code and how to optimize it, comfort and speed of writing code come second. Especially in long-term projects that are supposed to work for a few years. Why is it so important? Because if we will not have enough computing power in vertical scaling (more and more powerful machine), we have to transfer to horizontal scaling (cloud hosting, clustering, etc.). The price of rewriting the 1-instance application to a cluster one may exceed 100% of the project’s cost. Additionally, the price of adding a new machine is not proportional to the growth of profits and a firm has to decide on losses associated with scaling or has to limit access to the service and stop the progress. Progress is a basic rule of every firm (without it the firm will die in the span of 5 years). Hence it is better to choose a quick language and write a code 2 times longer (one-time cost) than paying triple for hosting every month.
There is another issue
The security of typing. I mentioned this, a few times already, typing works only within our code. The problem is data coming to our app from the outside – either 3rd party API or from a user. Us typing some kind of variable to string does not mean the app will check by itself the type of a variable after transpiring. If we will not write code that will check variable type the app will show errors, the same goes for JS. Two real-life examples – outside API changes its structure daily, without updating to a newer version (existing endpoints change, unfortunately, it happens sometimes). If we will not write in a TS/JS code to check what kind we get will not get the app to work. The second one, the communication between Frontend and Backend. We made a joint interface for data exchange (ex. Email/password - 2 strings), In TS everything compiles in frontend and backend, but we did not type in a line to check the type and instead of strings we send objects. Bam backend error.
Retranspiling the code
Every change in the code means compiling the whole application, it takes only a few seconds, but during 8 hours of work we have to compile code about 300 times, we lose 15 to 30 minutes of waiting. And what if we have a serious error in code and we have to quickly fix production? When it comes to JS you can fix it in Git, throw it to the server, restart only one service, and if something is very urgent, we can change it directly on the server and do a quick restart - in an ideal world, this should not be done, but practice looks bit different. I personally fixed bugs in production versions this way many times. In TS we cannot directly edit code, we have to edit the source and compile it, which takes a lot of time. If we do not know if the change will help, we lose once again, a lot of time, and production is halted.
Typing is just great
But only if it is natively built-in into the language (Java, Rust). When it comes to transpiling code we are in deep shit. Additionally, I think best is the flexible languages, you type if you want, not because you have to. Deno is a promising option, a new baby from the creators of Node. In Deno, we have a natively built-in compiler TypeScript. We code in TS and the virtual machine transpile the code to Rust. No problems with efficiency unlike TS to JS to V8. Unfortunately, Deno is a starting project and we cannot be sure If we will one day see a stable version.
Afterthought, half in jest half-seriously, if you need typing because you are getting lost in code, you are not a programmer you are a dumb-dumb :P