Why JavaScript Needs Typescript
One of JavaScripts greatest strengths is how flexible it is, it is however also one of its biggest weaknesses as JavaScript allows you to get a lot done quickly however it allows for pretty much any style you want and this on any large project usually ends in chaos.
JavaScript in many ways is a mess, it has no doubt improved over these last few years with some significant improvements and new awesome ways to do things like fetch or spread and rest, even a pseudo-class style was added and all of this is great and it starts to revive the language, however the major issue JavaScript has is how you work with Objects. So In JavaScript everything is an object which is great until you find some code that had an oddly named object, how can you determine what properties are inside the object? Or what could be undefined? The same goes with functions if naming isn't on point the parameters can be a craps shoot and the return value could be anything from void to a function, you can't tell unless there is some other indicator or you read the function.
Now of course this isn't really an issue for smaller more simple things but as projects grow and get more complex, people come and go and before long you end up with a huge pile of code that can be difficult to make heads or tail of. This is where TypeScript comes in as it helps with static types, it makes it easy to understand what is going into a function and what we can expect out; we are able to define interfaces that provide clarity on what is inside this complex object and TypeScript on top of this helps with a lot of other things such as preventing unexpected null values or too many assumptions, in many ways TypeScript provides clarity.
I would assume most people who come from more rigid language backgrounds already understand the importants of types and why it is so important to figure out what is going on inside things, so I don't think that is every much of a hard sell, but to others from JavaScript or PHP heavy backgrounds it is probably harder to get them onboard.
Really it is just a good idea to get people using it and use to the language and how it works, in many ways you can ignore a lot of it and use JavaScript whilst getting peoples feet wet to the prospect, but overtime I expect most people will understand the benefit of it. And with ever growing support and adoption TypeScript is proving to be quite the force to shake up the JavaScript landscape and for the better.
Photo by insung yoon on Unsplash