Minimal TypeScript Project Setup

Goal

Set up a minimal TypeScript project from scratch.

Create the project

npm init -y
npm install --save-dev typescript
nano tsconfig.json
{
  "compilerOptions": {
    "module": "commonjs",
    "esModuleInterop": true,
    "target": "es6",
    "moduleResolution": "node",
    "sourceMap": true,
    "outDir": "dist"
  },
  "lib": ["es2015"]
}

Write your code

nano src/app.ts

Add your TypeScript code to src/app.ts.

Compile and run

npx tsc
node dist/app.js