Lesson 2 / 26
Setup & tsconfig.json
Install the compiler and configure the project with tsconfig.json.
Install & initialize
tsc --init generates a starter tsconfig.json with sensible defaults.
npm install -g typescript
tsc --version
npx tsc --init # creates tsconfig.jsontsconfig.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.
tsc app.ts # compiles to app.js
tsc # compiles whole project per tsconfig
tsc --watch # recompile on save