How to compile a Typescript file?
In this article are going to explore TypeScript and how to execute the same. TypeScript is an open-source programming language developed and maintained by Microsoft.
Setup for Typescript
You need to follow the below steps to work with typescript files −
Download & Install node.js and Node Package Manager(NPM).
Setup the NPM Environment variables for the typescript to work.
You can use the below command to check the Node & NPM version installed on your system.
For Node version
For NPM version
Note − We don’t need to explicitly install the NPM packages. Node will automatically download install NPM while downloading node.
Once the Node and NPM is installed, we need to install the Typescript on our system.
npm install -g typescript
In the below example, we have created a simple typescript file with 3 values i.e. greet, org, and tagLine. This file is in typescript. Now, we will use the below commands to compile this file into a JS file.
var greet : string = "Welcome to"; var org : string = "TutorialsPoint!"; var tagLine : string = "SIMPLY LEARNING!" console.log(greet+ " "+org ); console.log(tagLine);
var greet = "Welcome to"; var org = "TutorialsPoint!"; var tagLine = "SIMPLY LEARNING!"; console.log(greet + " " + org); console.log(tagLine);
The output of the above file on execution is shown below −
Welcome to TutorialsPoint! SIMPLY LEARNING!
- Related Articles
- comp_err - Compile MySQL Error Message File
- How to compile a java program
- How to Compile a Lua Executable?
- How to compile assert in Java?
- How to compile packages in Java
- How to Edit, Compile, and Execute a C++ Program?
- How to sort a 2D array in TypeScript?
- How to compile unsafe code in C#?
- How to compile code using Arduino IDE
- How to create objects in TypeScript?
- How to get substring in TypeScript?
- How to format strings in TypeScript?
- How to use Hashmap in TypeScript?
- How to create a two-dimensional array in TypeScript?
- How to compile a Python 3 app to an .exe using Tkinter?