Home

TypeScript

Allows you to catch errors earlier.

Tutorials:

General Knowledge

Build-in types JS types TS types

Custom types

Initial project set-up

Initialize a new Node.js project:

npm init -y

Install TypeScript:

# globally
npm i -g typescript

# locally
npm install typescript --save-dev

# verify install
tsc -v

Generate a TypeScript configuration file

tsc --init

Settings:

  • target: "ES2016", "ES2018"
  • rootDir: "./", "./src"
  • outdit: "./dist"
  • removeComments: true
  • NoEmitOnError: true

With config file, running tsc with no arguments will compile the whole project.

Compile TypeScript to JavaScript

Create a .ts file and add the code, for example:

console.log('Hello world!');

In terminal run:

tsc index.ts

This will generate a .js file.

Debugging TypeScript

Debug using VS Code.

Date:

Screen Dimensions