Typescript
November 14, 2026 2 min read

Understanding tsconfig.json

HS
HEMANT SINGH
Technical Writer & Educator

tsconfig.json is the configuration file of a TypeScript project.


It tells the TypeScript compiler (tsc) how to compile your TypeScript code into JavaScript and which type-checking rules to follow.


For example, it controls:

  1. Which JavaScript version should be generated.
  2. Which module system should be used.
  3. Where TypeScript source files are located.
  4. Where compiled JavaScript files should be stored.
  5. How strictly TypeScript should check your code.
  6. Which files should be included or excluded.


1. Creating tsconfig.json

Inside your project folder, run:

npx tsc --init

It generates a tsconfig.json file containing compiler options and documentation.


2. compilerOptions

This is the main configuration section.

Example:

{
"compilerOptions": {
"target": "ES2020",
"module": "CommonJS",
"strict": true,
"rootDir": "./src",
"outDir": "./dist"
}
}

A. target

Specifies which JavaScript version TypeScript should generate.

"target": "ES2020"

B. module

Specifies which module system should be used in the generated JavaScript.


C. strict

This is one of the most important options.

"strict": true

It enables a group of strict type-checking options.


D. rootDir

Specifies the directory containing your TypeScript source files.


E. outDir

Specifies where the compiled JavaScript files should be generated.


3. Other important compiler options


Option

Purpose

noEmit

Check types without generating JS

noEmitOnError

Don't generate JS if errors exist

sourceMap

Generate source map files

removeComments

Remove comments from generated JS

esModuleInterop

Simplifies interoperability with CommonJS modules

skipLibCheck

Skip type checking of declaration files

forceConsistentCasingInFileNames

Enforce consistent filename casing

declaration

Generate .d.ts declaration files



noEmit

"noEmit": true

TypeScript checks your code but doesn't generate JavaScript.

Useful when another tool, such as a bundler, handles compilation.


sourceMap

"sourceMap": true

Generates .js.map files.

These help debugging tools map generated JavaScript back to the original TypeScript source.


esModuleInterop

"esModuleInterop": true

Helps with importing CommonJS packages.