const name: string = "TypeScript"
const year: number = 2025
Lesson 2: Setting Up Your Environment
Let’s get a TypeScript project running in under five minutes.
Install
npm install -D typescript
npx tsc --init
The tsc --init command generates a tsconfig.json — the file that controls how
TypeScript checks and compiles your code.
Recommended strict settings
{
"compilerOptions": {
"strict": true,
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "Bundler"
}
}
Turning on
strictfrom day one saves you from migrating a loose codebase later.
Run npx tsc --watch and TypeScript will re-check your files every time you save.