TypeScript notes

Hello everybody,

today I want to make some notes of type script, or if to spell it correctly TypeScript.

So, few words about TS.

File extensions for TypeScript is .ts. 

TypeScript is superset of javascript which means that TypeScript understands javscript code. Also for execution TypeScript gots trasplied to javascript. 

What means transpilation? If to take analogy from C#, it looks like this:

wonderfulProgram.cs -> C# compiler -> wonderfulProgram.dll 

Now let compare it with TypeScript:

wonderfulProgram.ts -> TypeScript compiler ->  wonderfulProgram.js

Another important part of TypeScript is strong typing:

JavaScript TypeScript

var x;

x = 67;

x='some string'

x = {'first': 'some json data',

       'second': 'another json data'    }

var x = {'first': 'some json data',

       'second': 'another json data' }

//now you can't write something like 

x = 56;

In js world, you can assign any value to x. It can be string, it can be integer, it can be number or even json. But in TS if you put something into x ( for example json ), then you can't assign into it number. TS compiler says that you need to change your decision or intention.

Class based OOP

JavaScript TypeScript

function Apple(colour){

this.colour = colour;


function Apple(colour){

this.colour = colour;


class Apple{

   colour: string

constructor(colour: string){

     this.colour = colour



Compare your level of understanding if you look at js or ts part. Which one is easier to grasp. I admit that maybe for somebody it's easier to grasp left side, but for me personally it's easier to understand right part or ts world.

No Comments

Add a Comment