# Setup & tsconfig.json — TypeScript Fundamentals

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

> Install the TypeScript compiler, generate tsconfig.json and understand target, module, outDir and strict options.

## 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
```
