Installing TypeScript

View saved

Install Node.js first

TypeScript ships as an npm package. Install a current Node.js LTS release so you have node and npm available.

node --version
npm --version

Install the compiler

Install TypeScript globally for quick experiments, or as a project dependency for real work.

npm install -g typescript
# Or in a project folder:
npm init -y
npm install --save-dev typescript

Check tsc

The compiler should print a version number.

tsc --version

Know what tsc does

  • tsc checks types and emits JavaScript
  • Browsers and Node run the emitted .js, not the .ts source
  • Editors use the same type checker for inline errors
  • You can run TypeScript with npx tsx or ts-node for learning, but tsc is the standard compile step

Comments

One comment per signed-in account. Comments are saved with this page’s URL.