Skip to content

What is TypeScript?

Up to now, we’ve discussed various languages and Frameworks such as JavaScript and CSS. As with many of these languages, there can be common problems or be lacking in certain feature sets which consequently sets the platform for newer languages with improved functionality and syntanx to fill the gaps. This is the case with CSS and SASS, where the latter was created in order to create a more pleasant experience for developers in writing cleaner and more readable code but is simply a preprocessor for CSS (i.e the code will still be compiled in CSS regardless of how different the SASS code might be).

What we will be discussing today is of a similar concept: TypeScript. TypeScript is a programming language developed and maintained by Microsoft. As discussed above, TypeScript is a superset of JavaScript, meaning it is simply an extension of JavaScript. Take a look at the code below:


var animal = “Dog;”
console.log(`I love  ${animal}’s`);


var animal = “Dog”;
console.log(`I love  ${animal}’s`);

Notice how there is absolutely no difference between the two codes examples? Again, this is purely because TypeScript is an extension of JavaScript and not an entirely different language. Where the differences really exist are in one of the reasons TypeScript was created initially. Have a look we’ve slightly adjusted from the above:

var animal: string = “Dog”;
console.log(`I love  ${animal}’s`);

Notice how the syntax has changed slightly and the addition of ‘string’ in the variable declaration? TypeScript allows developers to be more explicit while defining variables and associated data types, and as a result is far more strict than JavaScript. As files begin to grow and link between one another, it becomes increasingly difficult to keep track of it, and by simply altering one line, it can affect an array of link files as well that may be dependent on what you just changed.

TypeScript’s goal is, as stated above, to create a more strict and less error-prone platform for developers to code and help to eliminate potential bugs and data type conflicts as early on in the development process as possible. TypeScript is a superset of Javascript which means that not only are TypeScript files compiled into JavaScript but you could technically also change the file extension of your ES2015+ JavaScript files (.js) to TypeScript (.ts) and they will work absolutely fine.