1. What Is TypeScript?
When the JavaScript was developed then JavaScript
development team introduced JavaScript as a client-side programming language.
But when people was using JavaScript then developer
get to know that JavaScript can be used as a server-side programming language
also. But When JavaScript was growing then the code of JavaScript became
complex and heavy. Because of this, JavaScript was even not able to full fill
the requirement of Object-oriented programming language. This prevents
JavaScript from succeeding at the enterprise level as a server-side technology.
Then TypeScript was developed by the development team to bridge this gap.
2. What TypeScript Really Do?
-- TypeScript Code is
converted into Plain JavaScript Code:: TypeScript code is not understandable by
the browsers. That’s why if the code is written in TypeScript then it is
compiled and converted the code i.e. translate the code into JavaScript.The
above process is known as Trans-piled. By the help of JavaScript
code, browsers are able to read the code and display.
-- JavaScript is TypeScript: Whatever code is written
in JavaScript can be converted to TypeScript by changing the extension
from .js to .ts.
-- Use TypeScript anywhere: TypeScript code can
be run on any browser, devices or in any operating system. TypeScipt is not
specific to any Virtual-machine etc.
-- TypeScript supports JS
libraries: With
TypeScript, developers can use existing JavaScript code, incorporate popular
JavaScript libraries, and can be called from other JavaScript code.
3. Advantages Of Using TypeScript Over JavaScript
-- TypeScript always point
out the compilation errors at the time of development only. Because of this at
the run-time the chance of getting errors are very less whereas JavaScript is
an interpreted language.
-- TypeScript is nothing but JavaScript and some additional features i.e. ES6 features. It may not be supported in your target browser but TypeScript compiler can compile the .ts files into ES3,ES4 and ES5 also.
-- TypeScript has a feature which is strongly-typed or supports static typing. That means Static typing allows for checking type correctness at compile time. This is not available in JavaScript.
Generally TypeScript takes the time to compilation which is the disadvantage of TypeScript.
4. Installation For TypeScript
TypeScript can be installed through three installation routes depending on how you intend to use it: an npm module, a NuGet package or a Visual Studio Extension.
If you are using
Node.js, you want the npm version. If you are using MSBuild in your project,
you want the NuGet package or Visual Studio extension.
You can use npm to
install TypeScript globally, this means you can use the tsc command anywhere in
your terminal.
To do this, run npm install -g typescript. This will
install the latest version.
You can install
TypeScript as a Visual Studio extension, which will allow you to use TypeScript
across many MSBuild projects in Visual Studio.
The latest version is
available in the Visual Studio Marketplace.
5. Simple Program And Compile Process For TypeScript