Image credit goes to CodeCademy.

Why TypeScript is cool.

Giorgi Gutsaev
3 min readJun 17, 2022

--

I recently had to look into TypeScript for a project I was assigned for at my company and I spontaneously decided to dedicate these humble tapestry of words to this beautiful superset of JavaScript (more on this below), which I had slept on for the longest time.

So, when I talk about programming languages, I like to generally categorise them into 2 easily-digestible groups: (for my sanity obviously, and for the sanity of people around me of course.)

  1. Group one: Loosely typed languages

Examples of Loosely-typed languages:

  1. Python
  2. Ruby
  3. JavaScript

A snippet of variable declaration syntax:

// variable declaration in JSlet myName = “John Doe”myName = “Steve”; // valid
myName = true; // valid
myName = 42; // valid
myName = []; // valid
myName = {} // valid

2. Group two: Strongly/Strictly typed languages.

Examples of Strongly-typed/Strictly typed languages:

  1. Java
  2. C#
  3. C++

A snippet of variable declaration syntax:

// general variable declaration in a strongly-typed languageString my_name = “John Doe”my_name = “Steve” // valid
my_name = true // invalid
my_name = 42 // invalid

.So what is typeScript 🧐 ?

TypeScript is a superset of JavaScript. Which in layman’s terms, means that it’s based on JavaScript, but contains so much more on top of it. TypeScript was developed and is maintained by Microsoft. It was launched for public use in October 2012. It was developed by Anders Hejlsberg, the lead architect of C#, as well as many other talented developers.

Remember how I mentioned in the beginning, that I like to group languages, into an unapologetically simple but distinctive groups? Yeah, TypeScript (even though it’s a rather lengthy extension of its third-cousin JavaScript), would fall into the strongly-typed category.

Illustrating the relationship between JS & TS.

With my initial reconnaissance efforts, I immediately gathered that TS was created with the idea — to shake off JavaScript’s innate nature of …’’weirdness’’. Don’t get me wrong, I love JavaScript, and I think it’s truly beautiful, but TypeScript provides so much more reliability. Now that I’ve mentioned reliability, I think it’s a perfect segue to discuss some of the reasons why most people choose it over JavaScript these days.

.Reason 1 — TypeScript minimises bugs in your codebase

Yes, thanks to Microsoft and the team behind it, with the addition of data typing and other important elements, our programs are now less susceptible to weird bugs.

.Reason 2 — Legibility

Again, due to the addition of strict types and features like enums for instance, we can make our code more self-expressive, and make it more legible for other team members (remember, software development nowadays is a team-effort). And code that’s legible and clearly demonstrates its initial intent, always wins.

.Reason 3 — True OOP?

I am not an experienced TypeScript engineer, but what I love about it, is that it gives us true Object Oriented features, such as interfaces, protected variables, protected functions, etc. This makes the code well-organised, easily maintainable, and most importantly scalable.

.Reason 4 — A more flexible development process

Developing with TypeScript is a pleasure. It always points out the compilation errors during the development phase, and because of this, I get less runtime errors.

.Le Fin

I mean there are pros and cons for everything right? And there is no “best” tool, all tools are there to solve a particular problem. I am grateful to have stumbled upon TS and it’s a joy to integrate TS inside my React Projects now.

Coding is just beautiful. Let’s enjoy the ride.

Check out my Github & follow me on Twitter

--

--

Giorgi Gutsaev

Software Developer @Cognizant UK. I love solving problems, JavaScript, kimchi & being curious in a digital world. Live to discover new frameworks & libraries!