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

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
主站蜘蛛池模板: 湘阴县| 廉江市| 宁波市| 安国市| 昭通市| 绩溪县| 个旧市| 兴宁市| 深泽县| 临澧县| 丽江市| 资讯 | 永丰县| 饶河县| 黑水县| 如东县| 临桂县| 类乌齐县| 上饶市| 鹤峰县| 子长县| 千阳县| 图木舒克市| 博兴县| 无为县| 利川市| 沭阳县| 光山县| 华宁县| 仙桃市| 普安县| 桂东县| 永新县| 丰宁| 鄂温| 黄冈市| 平湖市| 精河县| 甘泉县| 抚松县| 奉节县|