How to Setup Shared TypeScript Config in Turborepo


"Bhai har project mein
tsconfig.json
copy karna band karo… welcome to reusability, the Turborepo way!"
🧠 Why You Should Care
When working with monorepos, we often have multiple projects like:
apps/server
(Node.js backend)apps/web
(Next.js frontend)packages/ui
(component library)
Each project needs its own tsconfig.json
. But repeating the same config is a waste of time (aur battery bhi 😤).
Solution: Use a shared TypeScript config package in packages/typescript-config
.
📁 Project Structure Snapshot
Here’s how your monorepo folder should look:
🔧 Step-by-Step Guide
1. Create backend.json
in packages/typescript-config
// packages/typescript-config/backend.json
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"target": "ES2020",
"module": "CommonJS",
"moduleResolution": "Node",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"outDir": "dist",
"rootDir": "src",
"strict": true,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true,
"declaration": true,
"declarationMap": true,
"sourceMap": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}
2. Edit package.json
of typescript-config
// packages/typescript-config/package.json
{
"name": "@repo/typescript-config",
"version": "0.0.0",
"private": true,
"license": "MIT",
"publishConfig": {
"access": "public"
},
"exports": {
"./base.json": "./base.json",
"./backend.json": "./backend.json",
"./nextjs.json": "./nextjs.json",
"./react-library.json": "./react-library.json"
},
"files": [
"base.json",
"backend.json",
"nextjs.json",
"react-library.json"
]
}
3. Use it in Your Server App
In apps/server/tsconfig.json
, use:
{
"extends": "@repo/typescript-config/backend.json",
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
✅ Bonus tip: You can override or extend this config per project!
4. Add It as a Dev Dependency
In apps/server/package.json
:
"devDependencies": {
"@repo/typescript-config": "workspace:*"
}
"workspace:*"
means use the local version frompackages
.
Then install:
pnpm install
5. Final Server package.json
Example
{
"name": "server",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "nodemon --exec ts-node src/index.ts",
"build": "tsc",
"start": "node dist/index.js",
"check-types": "tsc --noEmit",
"lint": "echo \"No linting configured\""
},
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^17.0.0",
"express": "^5.1.0",
"socket.io": "^4.8.1"
},
"devDependencies": {
"@repo/typescript-config": "workspace:*",
"@types/express": "^5.0.3",
"@types/node": "^22.15.3",
"nodemon": "^3.1.10",
"ts-node": "^10.9.2",
"typescript": "^5.8.3"
}
}
🧠 Bonus: Why This Rocks
✅ No more copy-pasting
tsconfig.json
in every app✅ Easy to maintain and version
✅ Clean and scalable monorepo setup
✅ Looks cool when explaining to your junior 😎
💭 Final Thoughts
Once you get this pattern right, you can build and scale your Turborepo apps with a smile on your face (and fewer bugs 🐞).
Let your code be DRY, not your eyes. 🧂
If you liked this post, drop a 🧡 and follow me for more Turborepo & TypeScript tips.
Have any doubt or want the full template? DM me on Twitter or comment below!
Subscribe to my newsletter
Read articles from Abhishek Raut directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Abhishek Raut
Abhishek Raut
🔭 I’m currently working on Full Stack Project 👯 I’m looking to collaborate on Animated Websites 🌱 I’m currently learning Data Science 💬 Ask me about React GSAP ⚡ Fun fact I am Working on Project and learning tech stack used in That