tsconfig.app.json
π Technical Documentation: Configuration Files
tsconfig.app.json π
The tsconfig.app.json file is a TypeScript configuration file specifically tailored for the application's build process. It defines compiler options and specifies which files and directories should be included or excluded during compilation.
Purpose
The tsconfig.app.json file is crucial for:
- Configuring TypeScript compiler options for the Angular application.
- Including essential files such as the main entry point (
main.ts) and polyfills. - Ensuring the application adheres to the desired TypeScript standards.
File Structure
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": ["node"]
},
"files": [
"src/main.ts",
"src/polyfills.ts"
],
"include": [
"src/**/*.d.ts"
]
}
Explanation of Configuration
| Property | Description |
|---|---|
"extends" |
Inherits configurations from tsconfig.base.json to maintain consistency across the project. |
"compilerOptions" |
Specifies TypeScript compiler settings: |
- outDir: Output directory for compiled files. |
|
- types: Includes type definitions for Node.js. |
|
"files" |
Explicitly includes specific files needed for the app to run (e.g., main.ts and polyfills.ts). |
"include" |
Globally includes declaration files (*.d.ts) from the src directory. |
Key Features
- Extensibility: By extending
tsconfig.base.json, shared settings across multiple configurations are maintained, avoiding redundancy. - Type Definitions: Ensures compatibility with Node.js by including its type definitions.
- Focused Compilation: Targets only the application-relevant files for compilation.
Usage in the Project
The tsconfig.app.json is referenced in the Angular build process via the angular.json file under the build target configuration:
"tsConfig": "tsconfig.app.json"
This ensures the Angular CLI uses the specified TypeScript settings when building the applicationγ4:1β sourceγγ4:10β sourceγ.
Benefits
- π οΈ Streamlined Compilation: Simplifies the build process by focusing only on required files.
- π― Consistency: Promotes uniformity across the project by inheriting from a shared base configuration.
- π Efficiency: Enhances performance by excluding unnecessary files from the compilation process.
Pro Tip π‘
For further customization or to learn more about the tsconfig file, check out the official Angular documentation: Angular TypeScript Configuration.