Installation and setup

suggest change

Background

TypeScript is a typed superset of JavaScript that compiles directly to JavaScript code. TypeScript files commonly use the .ts extension. Many IDEs support TypeScript without any other setup required, but TypeScript can also be compiled with the TypeScript Node.JS package from the command line.

IDEs

Visual Studio

Visual Studio Code

WebStorm

IntelliJ IDEA

Atom & atom-typescript

Sublime Text

Installing the command line interface

Install Node.js

Install the npm package globally

You can install TypeScript globally to have access to it from any directory.

npm install -g typescript

or

Install the npm package locally

You can install TypeScript locally and save to package.json to restrict to a directory.

npm install typescript --save-dev

Installation channels

You can install from:

Compiling TypeScript code

The tsc compilation command comes with typescript, which can be used to compile code.

tsc my-code.ts

This creates a my-code.js file.

Compile using tsconfig.json

You can also provide compilation options that travel with your code via a tsconfig.json file. To start a new TypeScript project, cd into your project’s root directory in a terminal window and run tsc --init. This command will generate a tsconfig.json file with minimal configuration options, similar to below.

{"compilerOptions": {"module": "commonjs","target": "es5","noImplicitAny": false,"sourceMap": false,"pretty": true},"exclude": ["node_modules"]}

With a tsconfig.json file placed at the root of your TypeScript project, you can use the tsc command to run the compilation.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents