Introduction to TypeScript
Given below shows installation process:
1. First, Install Node js on your machine since NPM (Node Package Manager) is supported.
2. Go to the nodejs.org site and download it.
3. Install the Node js, then open the command prompt or terminal and check the version of a node using type node – v and hit the enter.
4. You can now set up Typescript by NPM. Once again, through your command prompt or terminal, type the next command to set up Typescript.
5. This command can install Typescript globally, allowing you to utilize it in every project. Following the set up finished, you may check the version by tsc -v.
6. You can now use Typescript. Generate a new file out of your code editor, and also an extension of this file should be .ts.
Let’s proceed while using key features of Typescript. Differ from JS; we are able to specify the types of each of our variables since the number, string, boolean, array, tuples, enums, any, and much more.
Beneath, you can observe a few examples of strong typing:
Object-Oriented Feature of TypeScript
It can be a simple object-oriented programming language offering solid features of this, including classes, interfaces, modules, inheritance, and so on.
For example, we can define a class:
We now have created a Human class, and also we could generate instances with the new keyword.
Once assigning the Human( ) object, we do not have to express their type again. It can be carried out instantly by Typescript.
In Object-Oriented Programming, we have an essential method known as a constructor( ). Every single class offers a default constructor method essentially, as well as being known as if we create an instance of this class:
In Object-Oriented Programming, access modifiers are utilized for limiting or permitting to access the variables of a class from external.
You will find 3 different kinds of access modifiers:
- Public: Allows access from beyond a class.
- Private : Doesn’t enable access from beyond a class.
- Protected : Allows access only in a class as well as derived classes.
Given below are the advantages mentioned:
- It can be a simple Object-Oriented programming language; it is simple to write a program in TypeScript with little understanding.
- This can be utilized for both client-side and also server-side development.
- It has superb tooling support with the IntelliSense, i.e., TypeScript program compilation as well as IntelliSense. Like a code can be added, IntelliSense gives effective hints.
- The program in TypeScript is much more readable. The programmer can also add or perhaps replace the program quicker since it assists them to keep in mind what every bit of code is described as.
- The program is easy as well as clean in TypeScript. Like the developers write the program that Static typing in TypeScript finds bugs that allow them to create a more robust program and keep it.
Why Should we Use TypeScript?
- Code refactoring in a dynamic language is additionally difficult developing harder to keep the good program; it can assist in program refactoring with the suitable software.
- Program quality can be carried out with the static analysis software that mainly uses static type programs. If so, TypeScript is great.
- Web browsers have no great execution of all of the features. You need to support older web browsers. It facilitates the characteristics and may compile down to older emit.
How will this Technology Help you in Career Growth?
- In contrast to React.JS Angular, it is mostly a total MVC platform, which can be important for any kind of decent size web application.
- This can be increasingly more famous in the Front end environment. Currently, many of these people want to work with or perhaps learn TypeScript within their future projects.
Those two factors are excellent, and they will help you to forecast a great future for the upcoming Five years.
This has been a guide to What is TypeScript? Here we have discussed the use, career growth, features and installation process of TypeScript. You can also go through our other suggested articles to learn more –