tsconfig.json
TypeScript's tooling helps you configure the compiler and your project via tsconfig.json
, so your code compiles exactly how you want it.
tsconfig.json
?This file tells the TypeScript compiler (tsc) how to compile your project — what files to include, target JavaScript version, module system, and more.
tsconfig.json
tsc --init
to auto-generate a tsconfig.json
with defaults.
target
: JavaScript version output (ES5, ES6/ES2015, ESNext, etc.)module
: Module system (CommonJS, ESNext, AMD, etc.)strict
: Enables strict type-checking options (recommended)outDir
: Output directory for compiled JS filesrootDir
: Directory containing source TS filesesModuleInterop
: Enables compatibility for importing CommonJS modulessourceMap
: Generates source maps for debugging# Initialize tsconfig.json tsc --init # Compile your project based on tsconfig.json tsc # Compile and watch for changes tsc --watch
Use esModuleInterop
and module
options for smooth interop with Node.js and bundlers like Webpack or Rollup.
my-project/ ├── src/ │ └── index.ts ├── dist/ │ └── index.js ├── tsconfig.json └── package.json