JavaScript is everywhere. It is used in every website you visit. JavaScript is an easy language to learn and program. But difficulty comes when we have to write large and complex programs. The first challenge we face is that JavaScript is an interpreted language and does not compile. We does not know the error in program until runtime. Second challenge, JavaScript is not an object oriented language. So, it is very difficult to write maintainable code.
TypeScript removes all the problems that developer faced during writing JavaScript programs. TypeScript is a superset of JavaScript language and helps to write JavaScript programs with compilation and using OOPS features.
TypeScript supports ECMAScript 3, ECMAScript 5 and ECMAScript 6 standards.
This TypeScript tutorial helps you to learn TypeScript in an easy way. Starting from Basics to Advanced concepts in step by step fashion.
Below are the Benefits / Advantages of TypeScript:
- Static Typing – TypeScript introduces some datatypes to JavaScript variables like number, string, boolean, any, object type. These datatypes helps you to use Static Typing feature of TypeScript and gives error when any wrong type is assigned to a variable. For example, if you define a variable ‘var1’ as number then you can not assign a string value to variable.
- Compilation – TypeScript compiles your code before execution and let you know about compilation errors like syntax errors and mismatch datatypes etc. Compilation is very useful when we have to write large JavaScript programs.
- Integration with popular JavaScript libraries using Declaration Files – TypeScript allows you to use other popular JavaScript libraries like JQuery to use within TypeScript code. Declaration files has extension “.d.ts” and contains each available function in a library. These declaration files provide intelligence when using library functions and variables.
- Support for Modules – TypeScript uses Module system. A module is just like a namespace in C# and a logical division of objects. A module is a container of objects. An object in a module is not available to outside world until you export them. You can import other modules and use their objects in your module. Module helps us to write maintainable code.
- Object Oriented programming features – Classes, Interfaces, Access modifiers – TypeScript allows you to use OOPS features like classes, interfaces, inheritance, generics and access modifiers like public and private variables. By using OOPS, you can develop logical modules and write efficient maintainable code easily.
In our next tutorial, we learn how to write our first TypeScript program using Visual Studio.