Skip to main content
In this lesson we’ll cover how to configure TypeScript using the tsconfig.json file. This file tells the TypeScript compiler how to process your project and is usually placed at the root of your repository.
A presentation slide titled “Configuring TypeScript” explaining that the tsconfig.json file configures the TypeScript compiler. It lists key settings like "compilerOptions" and the "include" / "exclude" options.
What tsconfig.json controls
  • compilerOptions: fine-tunes the compiler behavior and output.
  • include / exclude: determine which files are part of the compilation set.
Common compilerOptions Below is a quick reference table of commonly used compiler options and when you might change them. If you’re using a framework or starter template, it usually supplies a sensible tsconfig.json. For most projects, start with that and adjust only when necessary.
If you’re new to TypeScript, prefer the tsconfig.json that comes with your framework or starter project. It will usually have sensible defaults.
Example tsconfig.json A typical tsconfig.json you’ll encounter:
Enabling stricter checks Turning on additional checks helps catch bugs early. For example, noUnusedLocals and noUnusedParameters flag dead code, unused imports, and forgotten variables. Example of an unused local that will be flagged when noUnusedLocals: true:
Compiler message you might see:
TypeScript source example A small example showing imports and an exported entry point:
Compiler and syntax errors If your file contains syntax mistakes or typos, the compiler/watcher will report compilation errors. Example output from a dev server:
These errors commonly indicate typos (for example, expor instead of export) or malformed arrow functions. Package manager messages When adding dependencies you may also see warnings from your package manager. Example Yarn output:
Include / exclude patterns Use include to specify files or glob patterns to compile, and exclude to keep files out of compilation. Common patterns: Excluding node_modules is standard because third-party packages are generally precompiled and do not need type-checking from your project compiler. That concludes the section on configuring TypeScript.
A three-step horizontal timeline for a TypeScript tutorial with circular markers labeled 01, 02, and 03. The middle step, "Configuring TypeScript," is highlighted; 01 says "Importing in TypeScript" and 03 says "TypeScript Project — Best Practices."
Next steps This article also covers importing modules in TypeScript and common patterns for doing so. For deeper details see the official TypeScript docs: Keywords: TypeScript configuration, tsconfig.json, compilerOptions, include exclude, noUnusedLocals, esModuleInterop, strict mode, TypeScript troubleshooting.

Watch Video

Practice Lab