0
0
Typescriptprogramming~10 mins

tsconfig.json Configuration Basics in Typescript - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - tsconfig.json Configuration Basics
Start: Create tsconfig.json
Add compilerOptions
Set target, module, strict, etc.
Add include/exclude files
Run tsc compiler
Compile or show errors
End
This flow shows how tsconfig.json is created and configured to control TypeScript compilation.
Execution Sample
Typescript
{
  "compilerOptions": {
    "target": "ES6",
    "module": "commonjs",
    "strict": true
  },
  "include": ["src/**/*"]
}
A simple tsconfig.json that sets ES6 target, commonjs module, strict mode, and includes all files in src folder.
Execution Table
StepActionConfig KeyValueEffect
1Create tsconfig.json file--File created with default empty content
2Add compilerOptions objectcompilerOptions{}Prepare to set compiler options
3Set target optiontarget"ES6"Output JavaScript will use ES6 features
4Set module optionmodule"commonjs"Use CommonJS module system for imports/exports
5Enable strict modestricttrueEnable strict type checking rules
6Add include arrayinclude["src/**/*"]Only files in src folder are compiled
7Run tsc compiler--Compiler reads tsconfig.json and compiles accordingly
8Compilation success or errors--Output JS files or show errors based on config
💡 Compilation ends after processing all included files with specified options
Variable Tracker
Config KeyInitialAfter Step 3After Step 4After Step 5After Step 6Final
compilerOptionsundefined{"target":"ES6"}{"target":"ES6","module":"commonjs"}{"target":"ES6","module":"commonjs","strict":true}{"target":"ES6","module":"commonjs","strict":true}{"target":"ES6","module":"commonjs","strict":true}
includeundefinedundefinedundefinedundefined["src/**/*"]["src/**/*"]
Key Moments - 3 Insights
Why do we need the "include" field in tsconfig.json?
The "include" field tells the compiler which files to compile. Without it, the compiler might compile all files or none, depending on defaults. See execution_table step 6.
What does setting "strict": true do?
It enables strict type checking rules, making TypeScript catch more errors early. This is shown in execution_table step 5.
What happens if we omit the "target" option?
The compiler uses a default JavaScript version (usually ES3 or ES5), which might not support newer features. See variable_tracker for how target is set.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the value of "module" after step 4?
Atrue
B"ES6"
C"commonjs"
Dundefined
💡 Hint
Check the 'Value' column at step 4 in execution_table.
At which step does the compilerOptions object first get a property set?
AStep 2
BStep 3
CStep 5
DStep 6
💡 Hint
Look at execution_table where 'target' is set inside compilerOptions.
If we remove the "include" field, what changes in the compilation process?
ACompiler compiles all files by default
BCompiler compiles no files
CCompiler throws an error
DCompiler only compiles files in node_modules
💡 Hint
Refer to key_moments about the role of 'include' in execution_table step 6.
Concept Snapshot
tsconfig.json controls TypeScript compilation.
Use "compilerOptions" to set target JS version, module system, and strictness.
Use "include" to specify files to compile.
Run tsc to compile using this config.
Missing options use defaults.
Strict mode helps catch errors early.
Full Transcript
This visual trace shows how tsconfig.json is created and configured step-by-step. First, the file is created empty. Then, the compilerOptions object is added. Next, target is set to ES6, meaning the output JavaScript will use ES6 features. The module system is set to commonjs for imports and exports. Strict mode is enabled to catch more errors. The include field is added to specify that only files in the src folder are compiled. Finally, the TypeScript compiler reads this config and compiles the files accordingly, producing JavaScript or showing errors. Variables like compilerOptions and include change as options are added. Key moments include why include is important, what strict mode does, and what happens if target is missing. The quizzes test understanding of these steps and values. This helps beginners see how tsconfig.json controls the TypeScript build process.