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

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
主站蜘蛛池模板: 瑞金市| 台江县| 泰宁县| 洛川县| 萍乡市| 鄂州市| 定西市| 深泽县| 高淳县| 红安县| 两当县| 横山县| 镇沅| 论坛| 黑山县| 响水县| 营口市| 高陵县| 四会市| 石首市| 巫溪县| 龙海市| 阳江市| 宝清县| 玛多县| 山东省| 桦南县| 儋州市| 沁水县| 南雄市| 饶河县| 青川县| 凌海市| 石棉县| 贵定县| 读书| 巩义市| 孙吴县| 巴中市| 青海省| 沾化县|