TypeScript Environment Setup

This article is about TypeScript environment setup.

Install TypeScript Dependencies

Following subsections show, installing TypeScript Dependencies in Mac.

Install node.js

install the latest node js version.

brew install node

Check installation using below command

node --version

Output should be like

v16.13.2

Install npm

npm installation should come with node installation.

Verify the npm installation using below command

npm --version

Output should be like

8.1.2

Install typescript npm Package

We use npm to install TypeScript.

Use below command to install TypeScript

npm install -g typescript

If you face insufficient access error, use with sudo,

sudo npm install -g typescript

Install ts-node npm Package

ts-node is the cli utility to compile typescript from terminal.

Use below command to install ts-node

npm install -g ts-node

If you face insufficient access error, use with sudo,

sudo npm install -g ts-node

Install pacel-bundler

parcel-bundler helps in compiling typescript code in html scripts to javascript for browser to run. Parcel Bundler comes with web server.

npm i -g parcel-bundler

To run the web server,

parcel <html-file>

Example

parcel index.html

Set Up Visual Studio Code

Install vscode using below command

brew install --cask visual-studio-code

Add code Path

Using this, we should be able to launch vscode from cli.

  1. Open Visual Studio Code and enter cmd + shift + P
  2. Enter: install 'code' command in PATH and enter

Install Prettier Extension

Install pritter extension from extensions tab in vscode as shown below.

Prettier Extension
Prettier Extension

typescript programming

Subscribe For More Content