Recently I looked into TypeScript. I had been working on a project that was growing rapidly. The downside was that the project was breaking continuously. We needed a way to fix it. TypeScript seemed like a good idea but we had our reservations.
Turns out TypeScript was the perfect solution for us. It strengthened our code base and reduced the number of bugs we introduced.
The first concern that I had was “can we move all of our code to TypeScript?”. WI think that this was fairly reasonable to ask since usually changing languages is a laborious process.
Then we rename app.js to app.ts making it a TypeScript file. The compiled output of the application is this:
This is something that I did not find to be clear enough when first looking at TypeScript.
One view that I have come to have regarding TypeScript is that it does not exist. I don’t mean that it is not a language, I simply mean that when your code is running on your web page there are almost no signs that TypeScript was ever there.
Lets take the toy function from before and add type information.
As you can see, the TypeScript code is gone. It operates as a very powerful development time tool. Making sure that as a developer I don’t use the wrong types within the codebase.