If you are a JavaScript guru than you’ve probably heard of TypeScript before, and maybe even had the opportunity to work with it, but for a beginner there is a highly chance that you get confused and even intimidated by the term “TypeScript”, So in this post we will get to know a little bit more TypeScript and what is all about, and even correct some misconceptions and what does TS (TypeScript) brings exactly to the table, So let’s start shall we 😀 .

TypeScript is a superset of JavaScript

TypeScript vs ES6 vs ES5
Diagram showing the relationship between ES5,ES6 and TypeScript
TypeScript is a result of a fruitful collaboration between the two tech heavyweights Google and Microsoft, and actually a superset of ES6 which in his part is a superset of ES5 (Plain good old JavaScript that we all love), I had to get that out of the way as soon as possible before JavaScript’s die hard fans start roasting me haha .
For the current time there are a few of browsers that support it and so to run it we need a Transpiler and what is great about transpiler that they make the process of updating the languages easy ,smooth and without forcing everyone to update their browsers .

So What does make TypeScript unique from Good Old JavaScript

TypeScript the king of strong type
If you are a Wrestling fan then you will get this reference
  1. Types

    Surprise, surprise!! who could guess that Types are the most known feature of TypeScript (forgive my poor sarcasm attempt :p), but seriously for me one of the problem with JavaScript is the lack of types and some people may argument that is what gives JavaScript it charm but having a types checking mechanism will help you a lot especially in :

    • writing code by preventing bugs at compile time .
    • and also reading code by clarifying intentions for potentials team members .

    with the next small example i will try to show case the power of types in TypeScript:

    function hello(name: string): string {
    return 14;

    In TypeScript this will generate a compilation error which will made the process of fixing it much easier, but with JavaScript in the other hand this will compile and you will not notice the bug what will made the process of debugging more complicated especially in a big project with thousand lines of code.

    Built in Types :

    Nothing fancy here just the ordinary built in types such as : String,Number,Boolean,Array,Enum,void (heavily used in functions as a return type) and last but not least is Any which is the default type and allows to receive any kind of value .

  2. Classes

    ES5 JavaScript doesn’t use Classes but instead relies on prototypes to have that object oriented programming approach, how ever in ES6 we finally have that built-in classes and we define one like so:
    class Car {

    Classes can have: properties, methods, and constructors.
  3. Inheritance

    One of the most important functionality in object oriented programming is class inheritance, and as the name suggests a class is gonna inherit another class’s (parent class) behaviors (methods, instance variables).
    Inheritance in TypeScript is achieved by adding the extends keyword:

    class Vehicle {
    class Car extends Vehicle{
  4. The Future Of TypeScript

    It’s very hard to predict the future in the programming world, but like I said above that TypeScript is an official collaboration between the two biggest names in tech today Google and Microsoft, adding on top of it the fact that from Angular2 and up, TypeScript is the recommended language to use with, so with that being said it’s pretty safe to guess that TypeScript have a bright future ahead of it, and it will be supported for a long time.
  5. Wrapping Up

    So this was like TypeScript in a nutshell, i hope it answered your questions and misconceptions about the language, and if you want to get even more in depth content I suggest reading ng-book: The Complete Guide to Angular 4, which this post was heavily influenced by, and if you enjoyed the post and want to show appreciation to the writer just share, like and follow us on social Media.
    Take Care !! until another Post with TechTalko

See Also: what is a lean canvas and why it’s a must have for every startup



Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.