To work with typescript, NodeJS and TypeScript are required. You may use any text editor to create a .ts file and use tsc command in cmd prompt to compile ts file to js file. One can also consider an IDE like Visual Studio Code that could help write TypeScript with ease.
Based on your OS version, you can download node from [https://nodejs.org/en/] and run the installer that guides you through simple steps. To verify if node is installed, run
node -v command in cmd prompt. node command should echo the version of node that is installed.
With node installed, we get npm installed inclusively. Open a command prompt as administrator and run the following command to install TypeScript compiler globally using npm :
npm install -g typescript
To verify if typescript is installed successfully, run
tsc -v in command prompt from any folder location. It should echo back the version of typescript being used as shown in the below screenshot.
We are done with the environment setup for TypeScript. Now, we shall cover the different concepts in TypeScript.
Conditional statement executes a block of statement based on an expression’s value. The branching of this execution can happen in many ways, and TypeScript provides statements for realizing this conditional branching of execution flow :
TypeScript Looping Statements
Often it is required to execute a task repeatedly based on a condition. TypeScript provides for, while and do-while to execute looping program structures.