Easy learning with example program codes

TypeScript Overview Tutorial


TypeScript is a superset of JavaScript which primarily provides optional static typing, classes and interfaces. One of the big benefits is to enable IDEs to provide a richer environment for spotting common errors as you type the code.

TypeScript doesn’t run in the browser. The code written in typescript is compiled to JavaScript, which then runs in the browser.

TypeScript is open source. It was designed by Anders Hejlsberg (the lead architect of C#) at Microsoft.

Features of TypeScript:

  1. The code written in typescript is compiled to the JavaScript for the purpose of execution.
  2. As we already discussed that the code written in typescript is compiled to the JavaScript which can reuse all of the existing JavaScript frameworks, tools, and libraries.
  3. As TypeScript is a superset of JavaScript so any valid .js file can be renamed to .ts and compiled with other TypeScript files.
  4. TypeScript is portable i.e. it can run on any environment that JavaScript runs on.
  5. TypeScript provides optional static typing. JavaScript is dynamically typed. This means JavaScript does not know what type a variable is until it is actually instantiated at run-time. This also means that it may be too late. TypeScript adds type support to JavaScript. TypeScript makes typing a bit easier and a lot less explicit by the usage of type inference. For example: var msg = “hello” in TypeScript is the same as var msg : string = “hello”. TLS (TypeScript Language Service) provides the facility to identify the type of the variable based on its value if it is declared with no type.
  6. TypeScript supports Object Oriented Programming concepts like classes, object, interfaces and inheritance etc.
  7. TypeScript Definition file with .d.ts extension provides definition for external JavaScript libraries.
  8. TypeScript provides strict null checks. TypeScript compiler will not allow undefined to be assigned to a variable unless you explicitly declare it to be of nullable type. For example, let num1 : number = undefined will result in a compile error. This fits perfectly with type theory, since undefined is not a number. One can define x to be a sum type of number and undefined to correct this: let num1 : number | undefined = undefined.

TypeScript Tutorial

TypeScript Overview.
Typescript vs Javascript.
Typescript let vs var.
TypeScript Hello World.
Typescript Data Types.
Typescript Variable Declaration.
TypeScript operators list.
TypeScript Arithmetic Operators.
TypeScript Comparison Operators.
TypeScript Bitwise Operators.
Typescript Logical Operators.
TypeScript Assignment Operators.
Typescript Conditional Operator.
Typescript String Operator.
Typescript typeof Operator.
TypeScript control statements.
TypeScript Switch Statement.
TypeScript for loop.
TypeScript for in loop.
TypeScript while loop.
TypeScript do while loop.
Typescript for loop break.
TypeScript for loop continue.
Typescript function.
Typescript returning function.
Typescript parameterized function.
Typescript function optional parameter.
Typescript rest parameters.
Typescript default parameters.
Typescript anonymous function.
Typescript function constructor.
Typescript Arrow/Lambda function.
Typescript function overloading.
TypeScript number object.
TypeScript string object.
TypeScript boolean object.
TypeScript date object.
TypeScript math object.
TypeScript array object.
TypeScript tuples.
TypeScript union type.
TypeScript interface.
TypeScript interface inheritance.
TypeScript interface multiple inheritance.
TypeScript class.
Typescript class inheritance.
Typescript class interface.
TypeScript abstract class.
TypeScript object.
TypeScript duck typing.
TypeScript NameSpace.
TypeScript Multi-file namespaces.
TypeScript module.
TypeScript ambient module.

Copyright © 2018 CodesJava Protection Status SiteMap