Smart {Code};

samuel-martins

Hi there, I am a full-stack developer. I love sharing my knowledge of development technologies and programming in general. Subscribe to get notified anytime I publish.

6 Likes Share

I have been putting writing this article off for a while now, but I thought it would be nice to share my thoughts on TypeScript as something that you might want to add onto your belt. TypeScript is a fairly new programming language. Since 2012, the language has become massively popular to the point of taking over front-end development, especially in large applications. Simply put, it is an enhanced version of JavaScript.


The relationship between TypeScript and JavaScript is similar to that of C and C++. The nice thing about TypeScript is that it is interchangeable with JavaScript. Any TypeScript code can be transpiled and translated into native JavaScript. You can therefore use the JavaScript that you already know inside of TypeScript. Most developers are adopting the use of TypeScript because you can use all its features, then translate into a native JavaScript file when you need to run it. Doing this may seem redundant at first because you can do a lot with plain old JavaScript, but TypeScript has better features.


TypeScript shines when it comes to large scale projects and enterprise-level applications. The use of TS should be judicial though because it would be a little bit of an overkill to use it for small side projects or an application where you merely have one or two JS files. I think one should reserve its use when you get to a point where you have a lot of structure involved in your program.

If you know JavaScript, you pretty much already know TypeScript, anything you can write in native JavaScript, you can write in TypeScript almost line for line. The core features it adds is the ability to add static typing to JavaScript. This feature does not change the fact that JavaScript is a dynamically typed language, nor does it change anything during runtime. It just means that when you are writing TypeScript code, you have type enforcement and you can choose if you want to declare the type of variables, method, parameters, return types, whatever it may be. The reason static typing is so important is that it comes with so many different advantages.


When you have static typing, and you have type reinforcement, the first thing that is a big deal is that catching errors becomes a lot easier. In dynamically typed languages like Python or JavaScript, almost all your errors are happening at runtime. That raises a lot of issues because you have to figure out what the problem is at runtime, which is more complicated than before, at compile time. There are also chances that you may miss errors because they just have not run yet. Take Python as an example, you can write some random code that makes no sense, but it will still run. Unless you hit that line of error-prone code, you may never know that that error exists, which is the same as in JavaScript.


When you have TypeScript, about 90% of the errors that you are commonly getting in a dynamically typed language, will be eliminated. How? In TS, the errors will be visible to you before you can even execute the program. You are going to have to fix the errors even before running your code. Without TS, you are going to have to debug your code at runtime that will require the use of a debugger which you might not have access to. This becomes hard for the most part when you are dealing with a large scale software, that is going out to millions of people. You want to make sure that you are catching all those bugs, especially any detrimental ones, and that you are getting them in your IDE before you go to the software. The idea is to give your IDE more information about your code so that it can do more work for you. Think about it this way. If you can have your IDE carry a lot of the weight, you will be saving yourself time and probably a bit of money too, especially if you are paying employers to code.


TypeScript comes with a bunch of other great features too, but the one I wanted to dial in on here is “typing”. Some people might think that it is going to be hard because you have to declare the types. It is not very difficult. The thing to take home here is that using this technology is entirely optional. If you are in a situation where it does not make sense to use it, you do not have to. In my opinion, TypeScript is a great language. It is an easy language to pick up specifically if you already know JavaScript. It just makes things way more powerful.


I have seen people online saying that it takes a little bit longer to write because you have to put the types. It is true, but I think that that is a marginal difference. I believe the types are just way more beneficial than they are harmful, and I would encourage all of you to look into TypeScript. Do not be intimidated by it. If the doubt comes along, just remember that TypeScript is just JavaScript on steroids. It is a great language to add to your resume because it shows that you are keeping up with trends. If you are already familiar with JavaScript, why not?

Related Posts . . .


 11th Aug 2021

Why ‘No Code’ Website Creation Services Will Not Be Stealing Your Job As Web Developer Any Time Soon

Today I feel like writing about web development jobs and the services we offer as web developers. I have always wanted to have the power to manipulate code to my

 11th Aug 2021

How Many Programming Languages Do You Need to Know?

How many programming languages do you need to know as a developer? The main reason for this question is that most newbies see a lot of developers out knowing

 11th Aug 2021

3 Lies Software Developers Put On Their Resume

How many jobs have you applied to this year alone? How many jobs have you landed? Is there a common denominator? Is there an art to job applications? Lately, I have