官术网_书友最值得收藏!

Installing TypeScript

It's pretty simple to install and get started with TypeScript. It is necessary to have Node.js and Node Package Manager (NPM) installed on your machine.

If you don't have them yet, go to https://nodejs.org/en/download/ and follow the step-by-step installation instructions for your platform.

Let's install TypeScript, as follows:

  1. Open your Terminal and type the following command to install the TypeScript compiler:
npm install -g typescript

Note that the -g flag means to install the compiler on your machine globally.

  1. Let's check the available TypeScript commands. Type the following command in the Terminal:
tsc --help

The preceding command will provide a lot of information about the TypeScript compiler; we will see a simple example of how we can transpile a TypeScript file to a JavaScript file.

Examples:

 tsc hello.ts
 tsc --outFile file.js file.ts

Descriptions of the preceding lines are as follows:

  • The tsc command compiles the hello.ts file.
  • Tell the compiler to create an output file, named hello.js
主站蜘蛛池模板: 双城市| 南康市| 安溪县| 汽车| 平凉市| 大渡口区| 逊克县| 丰城市| 琼结县| 阿拉善盟| 盐亭县| 萨嘎县| 宝山区| 安吉县| 合肥市| 长兴县| 东阳市| 西峡县| 周宁县| 漳平市| 山阴县| 托克托县| 阿荣旗| 佛学| 且末县| 鹤山市| 都江堰市| 钦州市| 定南县| 离岛区| 凤翔县| 松滋市| 永城市| 阳朔县| 方城县| 峨山| 屏东市| 慈溪市| 石嘴山市| 林州市| 东城区|