Skip to content

Instantly share code, notes, and snippets.

@mschwarzmueller
Last active November 2, 2025 21:22
Show Gist options
  • Select an option

  • Save mschwarzmueller/2ba4a82da34298d7a545269256ed6acf to your computer and use it in GitHub Desktop.

Select an option

Save mschwarzmueller/2ba4a82da34298d7a545269256ed6acf to your computer and use it in GitHub Desktop.
A good default tsconfig.json file - for frontend projects & Node.js
{
"target": "ES2022", // Good for modern browsers or Node.js
"compilerOptions": {
"esModuleInterop": true, // Ensures ESM and CJS imports work together well
"skipLibCheck": true, // Ensures .d.ts files from 3rd libraries are not type-checked
"target": "es2022", // Sets a relatively modern ECMAScript version as compilation target
"allowJs": true, // Allows importing .js files into .ts (helpful when migrating projects)
"strict": true, // Ensures strict type checking (i.e., noImplicitAny etc)
"noUncheckedIndexedAccess": true, // Adds undefined as a value when accessing by index
// "noImplicitOverride": true, // Enable this when working with classes & inheritance
"noUnusedLocals": true, // to avoid unused variables
"module": "NodeNext", // Supports both ESM & CJS modules / imports; Consider using ESNext for frontend projects
"outDir": "dist", // Store compiled files in "dist" folder
"sourceMap": true, // Enables source maps for easier debugging
"lib": ["ES2022", "DOM", "DOM.Iterable"] // Or without "dom" libs when building for Node
}
}
@mschwarzmueller
Copy link
Author

This is a very basic tsconfig.json file - it will not work well (or at all) when using a bundler or build tool like Vite.

That's on purpose as you'll typically create a project based on a template or with a tool like Vite when using a more complex build workflow. In those cases, a fitting tsconfig.json file will typically be generated for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment