Quick TypeScript Learning

TypeScript Language is the superset of JavaScript. In JavaScript have various coding structure available. That confused us for developing.  But TypeScript Has some mentions features which help us to write coding for JavaScript easily. In this article, I try to explain how easy to use TypeScript. And I will be give some best reference for TypeScript.

TypeScript a programming language which top of JavaScript & NodeJS compiler. If you wanted to execute your TypeScript code then must be installed NodeJS environment.

Then you need to write this code in your command prompt in windows npm install -g typescript . And If you are Linux/Mac OS X user then use sudo npm install -g typescript . After Then Write a sample code with *.ts extension.

After Installation check, your installation is working properly or not then you open command prompt in windows and terminal in MacOS and Linux. Then type tsc -v  and you can findout the version of TypeScript.

Lets we can start writing our TypeScript Code. You can use VisualStudio Code Editor is the one of the best coding editors now.

Let’s understand about the declaration of variables. In TypeScript, we are using let, const, var keywords.

let using for scoping of the variables. const using for constant value which is not changed entirely program. var is dynamic variables type and values assigned in the program.

In TypeScript, we can be assigned variables types. Like, let name: string = 'Sujoy'

Now I am giving some coding example in bellow:-

Programming Basics:-

Variables Declaration:

Conditional Syntax: if, if…else, if…elseif…else, switch…case, ?:(Ternary)

Conditional Oparators: == (EqualTo), != (Not Equal), > (Gratter Than), < (Less Than), >= (Gratter Than Equal), >= (Less Than Equal) etc.

Conditional Coding  example:

if Only




Ternary Condition:

Now we can be understood about loops. Loops are the process of continual programs. Which can be the incremental or decremental process. Four kinds of loops are available. eg. while, do…while, for, for…of

While Loop:


For Loop:

For…of Loop:

Function Declarations:

Class in TypeScript And Uses:

Interface and Implements:

Enum Datatype in TypeScript:

The module is another important part of JavaScript, It also important in TypeScript Also. When We want to connect a file object, functions or class. Then we need to use export keyword before object, functions or class. And when we import object, functions or class then we use import keyword. How it works. I give some example in below:-

The library can then be used as an import within modules:
Another Example:




In angular have so many decorators function. So I think it is some important to know about the concepts of decorators. Below examples, you can understand the uses of the Decorators.
After Writing this code you need some other setup in TypeScript.

Command Line:


This is all about typescript. You want to know more about typescript. then you can read typescriptlang.org. I want to know feedback for this article.

One thought on “Quick TypeScript Learning

Leave a Reply

Your email address will not be published. Required fields are marked *

eleven + fourteen =

Comment moderation is enabled. Your comment may take some time to appear.