You need to have Node.js and NPM installed.
We can install the TypeScript from the NPM package manager.
npm install -g typescript
The -g in the command means that the Typescript is installed globally so we can use the TypeScript in any of our projects.
Test that the TypeScript is installed correctly by typing tsc -v command
For help on the specific command, you can type tsc -h or just tsc to find the help.
Run and Compile:
The below command will convert the .ts file into a .js file
This command will create an app.js file
To compile multiple files:
tsc first.ts second.ts
This will create first.js and second.js file
You can also use the wildcards to compile all the files in a particular folder.
You can also compile all your Typescript files to a single one js file. This can significantly reduce the number of HTTP requests to browsers. We can use the –out command for it.
tsc *.ts –out combined.js
It’s the syntax you follow to make you more/less productive and error-prone.
When there’s an argument in function or method call, you can cover your code with types. To annotate, follow the variable or argument name with a colon followed by its type.
That’s it. We will meet soon with some practical demo.