All Guides
TypeScript Setup and Configuration
Add TypeScript to your project and configure tsconfig.json.
Beginner10 min
Setup Steps
1. Install TypeScript:
npm install -D typescript2. Create tsconfig.json:
npx tsc --init3. Recommended tsconfig.json settings:
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "bundler",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"outDir": "./dist",
"rootDir": "./src",
"declaration": true,
"sourceMap": true,
"resolveJsonModule": true,
"isolatedModules": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}4. Compile:
npx tsc5. Watch mode compilation:
npx tsc --watch6. Run TypeScript with Node.js:
npm install -D tsx
npx tsx src/index.ts7. Type definition files:
npm install -D @types/node @types/express8. package.json scripts:
"scripts": {
"build": "tsc",
"dev": "tsx watch src/index.ts",
"start": "node dist/index.js"
}Related Guides
Deploy to Vercel
Deploy your Next.js or React project to the Vercel platform.
Deploy to Netlify
Deploy your static site or JAMstack project to Netlify.
Bun Runtime Setup
Install the Bun JavaScript/TypeScript runtime. A fast alternative to Node.js.
Deno Setup
Install the Deno JavaScript/TypeScript runtime. A secure and modern alternative.