# Setup & tsconfig.json — TypeScript

Source: https://www.geekswithgeeks.com/en/typescript/ts-setup

> Install the compiler and configure the project with tsconfig.json.

## Install & initialize

`tsc --init` generates a starter `tsconfig.json` with sensible defaults.

```bash
npm install -g typescript
tsc --version
npx tsc --init     # creates tsconfig.json
```

## tsconfig.json essentials

`target` (JS version to output), `module` (module system), `outDir`/`rootDir` (file layout), and `strict` (turns on every strict check) are the settings you'll touch most.

## Compiling with tsc

`tsc` reads `tsconfig.json` and emits plain `.js` files that any JS runtime can run.

```bash
tsc app.ts          # compiles to app.js
tsc                 # compiles whole project per tsconfig
tsc --watch          # recompile on save
```
