Introduction
Hi friends!
In this series of articles, we are going to learn TypeScript with all the features of TypeScript 1.x along with TypeScript 2.0. But, before proceeding for details, let’s start with the very first question that always arises in front of all Server-side developers. If all applications will support only JavaScript frameworks like JavaScript, jQuery, and AngularJS, etc., what will be the future of Server-side programs?
Well, don’t worry about that. Here is the answer. Microsoft always helps with the new updates in Visual Studio along with new programming languages to support all Microsoft Technology developers. TypeScript is a new language built by Microsoft. So, let’s see more about that.
Q. What is TypeScript?
Answer - As per the official document of TypeScript, TypeScript is an open-source programming language and a Superset of JavaScript that compiles to plain JavaScript.
Q. How Does TypeScript Compiler Convert TypeScript to JavaScript?
Answer - TypeScript has its own syntax and types but JavaScript doesn’t. So, TypeScript uses a “transpiler” that converts our TypeScript code (i.e. ES6 + types) to ES5 or ES3 JavaScript code so we can use it in today's browsers.
It is mainly used for making large scale applications in JavaScript. The TypeScript compiler is itself written in TypeScript. We can write our code in TypeScript syntax and when the .ts code file is saved, it automatically creates a new file into your solution as Code.js; just use this output Code.js file as a Script file reference into your view, like .html file.
If you are a web developer with a rich experience of server-side languages like ASP, ASP.NET, or JSP, you must be familiar with OOPS; but JavaScript is Object-Based Script language. Maybe you are not so comfortable with dynamic languages but TypeScript gives you some features with them so you can solve the problem of static type and interfaces, class, inheritance, and many more behaviors of OOPs like we have in C# or Java, to make you feel comfortable.
Q. What are the features of TypeScript?
Answer - TypeScript has lots of features. The important ones are given below.
Features of Typescript
- Type annotation and compile-time checking
- Support classes.
- Support Modules for modular programming.
- Allow to use Interfaces
- Enumerated Type
- Generic
- Type inference
- Type erasure
- Namespaces
- Tuple
New Features from TypeScript 2.0
- Null- and undefined-aware types
- Control flow based type analysis
- Tagged union types
- The never type
- Read-only properties and index signatures
- Specifying the type of this for functions
- Glob support in tsconfig.json
- Module resolution enhancements: BaseUrl, Path mapping, rootDirs and tracing
- Shorthand ambient module declarations
- Wildcard character in module names
- Support for UMD module definitions
- Optional class properties
- Private and Protected Constructors
- Abstract properties and accessors
- Implicit index signatures
- including built-in type declarations with --lib
- Flag unused declarations with --noUnusedParameters and --noUnusedLocals
- Allow duplicate identifiers across declarations
So, that was all about TypeScript features and descriptions. In the next article, we’ll see the environment setup and how to create your first program with TypeScript.
Thanks for reading this article and stay tuned with me for
more technologies.