What is tsconfig.json
What you'll learn: You'll discover what tsconfig.json is and why it's essential for every TypeScript project.
The Configuration File
When you run the tsc command (the TypeScript compiler you learned about earlier), TypeScript needs to know how to do its job. Should it compile everything in your project or just certain files? What version of JavaScript should it output? Where should compiled files go?
tsconfig.json is the instruction manual for the TypeScript compiler. It's a JSON file that lives in your project's root directory and tells tsc exactly how to process your TypeScript code.
Why It Matters
Without tsconfig.json, you'd need to pass numerous command-line flags to tsc every single time you compile. That's tedious and error-prone. Instead, you define your project's configuration once in this file, and TypeScript reads it automatically.
Think of it like a recipe card: instead of remembering every ingredient and step each time you bake, you write it down once and follow it consistently.
What It Does
The tsconfig.json file controls critical aspects of compilation:
- Which files to include or exclude
- What JavaScript version to target (ES5, ES6, etc.)
- Where to output compiled
.jsfiles - How strict the type-checking should be
- Module system to use
When you run tsc in a directory containing tsconfig.json, the compiler automatically uses those settings—no extra flags needed.
Key Takeaway: tsconfig.json is TypeScript's configuration file that defines how your project should be compiled, eliminating the need for manual compiler flags and ensuring consistent builds across your team.