Skip to main content

TypeScript Fundamentals

TypeScript:

TypeScript is a typed superset of JavaScript that compile to plain JavaScript.

Topics:
1.     Getting Started with TS
2.     Typing, Variables & Functions
3.     Classes & Interfaces
4.     TypeScript Modules

Why TypeScript?

Before why we need to understand the problems with writing JavaScript code.
1.     JavaScript is messier with un-maintained code.
2.     Enterprise-code is very complex and difficult to use proper types.
3.     Difficult to work on 1000’s lines of JavaScript code.
4.     Create variables as integers and below of the code it can be used as string in JavaScript.
To avoid these kind of JavaScript issues, TypeScript is introduced.

Is there any TypeScript Alternatives?

1.     DART (By Google)
2.     CoffeeScript
3.     eCma Script

TypeScript Features:

TypeScript works with 
1.     Any Browser
2.     Any Host
3.     Any Os
4.     Open Source
5.     Tool Support




TypeScript Code Hierarchy






TypeScript Tool / Framework Support

TypeScript support by many modern tools ex..

1.     Node Js
2.     Visual Studio
3.     Visual Code
4.     TypeScript PlayGround
5.     eXma

Declaration and Annotation




Declaration and Annotation

//any:

var data : any = ‘Siva’;
var details : any = 123;

//strings:

var Name : string = ‘Siva’;
var FirstName : string = ‘Kakarla’;

//array:

var names : string[] = [‘Siva’, ‘Rama’, ‘Krishna’, ‘Venkata’];
var Ages : number[] = [21,22,23,24];

//null:

var SaleDetails : any = null;
var DateOfSale : Date = null;
var Quantity : number = null;

//undefined:

var quantity : number;
var company : any;


Comments