Creating Your First tsconfig.json
You'll learn how to generate TypeScript's configuration file and what it contains by default.
Initializing Your TypeScript Project
Now that you know what tsconfig.json is (your project's TypeScript rulebook), let's create one. The easiest way is to let TypeScript generate it for you using the tsc command you verified earlier.
Open your terminal in an empty project folder and run:
tsc --init
This command creates a tsconfig.json file with default settings and plenty of helpful comments explaining each option.
What You'll See
When you open the generated file, you'll find it's quite long—around 100 lines—but don't be intimidated! Most lines are commented out (grayed out with //). TypeScript includes these comments as built-in documentation.
The active settings (uncommented lines) represent sensible defaults for most projects. You'll typically see things like:
target: Which JavaScript version to compile to (like ES5 or ES2016)module: How to organize your code modulesstrict: Whether to enable strict type checking (usuallytrue)outDir: Where compiled JavaScript files should go
Think of tsc --init like creating a new document from a template in Word—you get a pre-filled starting point with examples, but you can customize it later.
Why This Matters
Without this file, the tsc compiler uses default assumptions that might not match your needs. With tsconfig.json in place, TypeScript knows exactly how to handle your project, and you can simply run tsc without additional flags.
Key Takeaway: Use tsc --init to generate a starter tsconfig.json with documented defaults—it's your project's TypeScript blueprint, making the compiler aware of your preferences.