Thursday, August 3, 2017

Typescript Introduction


TypeScript is a typed superset of JavaScript that compiles(transpiles) to JavaScript.

TypeScript is a free and open-source programming language developed and maintained by Microsoft.

TypeScript is pure object oriented (with classes, interfaces etc.) and statically typed(type checking done at compile time to identify errors) like C# or Java.

JavaScript is TypeScript. This means that any valid .js file can be renamed to .ts and compiled with other TypeScript files.


The TypeScript Compiler
The TypeScript compiler is itself a .ts file compiled down to JavaScript (.js) file. The TSC (TypeScript Compiler) is a source-to-source compiler (transcompiler / transpiler).

Typescript file when compiled using tsc command creates javascript file



The TSC generates a JavaScript version of the .ts file passed to it. In other words, the TSC produces an equivalent JavaScript source code from the Typescript file given as an input to it. This process is termed as transpilation.
However, the compiler rejects any raw JavaScript file passed to it. The compiler deals with only .ts or .d.ts files.




Installing Node.js

Node.js is an open source, cross-platform runtime environment for server-side JavaScript. Node.js is required to run JavaScript without a browser support. You may download Node.js source code or a pre-built installer from following link −

 
Step 1 − Download and run the .msi installer for Node.
Step 2 – After successful installation verify version of node js installed using command node –v
Step 3 - install TypeScript
Use npm install –g typescript command as shown below to install typescript.
-g flag indicates it to install globally/in the root directory so that it will be available to all the applications on the machine.



Next Topic is
Basic Types in Typescript

If you have any queries/suggestions feel free to post it in comment.

No comments:

Post a Comment