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

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
主站蜘蛛池模板: 凤山市| 方山县| 安国市| 三门县| 华阴市| 宜都市| 沂南县| 曲松县| 新安县| 永登县| 莱阳市| 蕲春县| 肥城市| 富顺县| 长乐市| 仪陇县| 永修县| 遂溪县| 惠水县| 南川市| 南汇区| 望谟县| 阜阳市| 永平县| 大安市| 河池市| 司法| 霍山县| 定南县| 毕节市| 阿荣旗| 冷水江市| 延川县| 穆棱市| 恭城| 镶黄旗| 天气| 通辽市| 屏东市| 灵台县| 井研县|