How To Initialize A TypeScript Project
The steps
From empty folder to typed project
# 1. Make sure Node is installed (use a current LTS version)
node -v
# 2. Create a package.json
npm init -y
# 3. Install TypeScript (as a dev dependency — it's a build tool)
npm i -D typescript
# 4. Generate a tsconfig.json (the compiler's config file)
npx tsc --init
# 5. Compile your .ts files to .js
npx tsc
What each piece does
npm init— createspackage.json, the project manifest.npm i -D typescript— installs thetsccompiler locally. It's a dev dependency because it only runs at build time, never in production.tsc --init— scaffolds atsconfig.jsonwith sensible defaults and every option documented.tsc— readstsconfig.json, type-checks your code, and emits JavaScript.
Install TypeScript locally (
-D), not globally. That pins the exact compiler version per project, so your build is reproducible on any machine and in CI.