Overview
The TypeScript configuration file (tsconfig.json) defines compiler options, file inclusions, and type-checking behavior for the Adosa Real Estate project.
Complete Configuration
tsconfig.json
Configuration Options
extends
Type:stringValue:
"astro/tsconfigs/strict"
Inherits TypeScript configuration from Astro’s strict preset.
astro/tsconfigs/strict preset enables:
- Strict type checking: All strict mode flags enabled
- Modern JavaScript features: Support for ES2022+ syntax
- Module resolution: Optimized for Astro’s file structure
- JSX support: Configured for Astro components
- Path mappings: Support for Astro’s special imports
The strict preset ensures maximum type safety and helps catch potential bugs during development.
include
Type:string[]
Defines which files TypeScript should process.
.astro/types.d.ts
Astro-generated type definitions:
- Auto-generated: Created during
astro devorastro build - Content collections: Provides types for content collections
- Image types: Includes types for Astro’s image optimization
- Environment variables: Types for
import.meta.env
src/**/*
Includes all source files recursively:
- Astro components:
.astrofiles - TypeScript files:
.tsand.tsxfiles - JavaScript files:
.jsand.jsxfiles (with allowJs) - Type definitions:
.d.tsfiles
astro.config.mjs
Includes the Astro configuration file:
- Enables TypeScript checking for config options
- Provides autocomplete in editors
- Validates integration options
Including the config file ensures type safety when adding integrations or modifying build settings.
exclude
Type:string[]
Defines which files/folders TypeScript should ignore.
dist
Excludes the build output directory:
- Build artifacts: Contains compiled and bundled files
- Performance: Speeds up type checking by ignoring output
- Prevents conflicts: Avoids checking generated code
Type Checking Commands
Check types
Editor Integration
Most editors automatically usetsconfig.json:
- VS Code: Built-in TypeScript support
- WebStorm: Native TypeScript integration
- Sublime Text: Via LSP plugins
Astro-Specific Type Features
Content Collections
Type-safe content queries:Component Props
Define prop types in Astro components:Environment Variables
Type-safe environment variables:Strict Mode Benefits
The strict configuration provides:1. Null Safety
2. Type Inference
3. Function Safety
Customization Options
While the current config is minimal, you can extend it:Add Path Mappings
Additional Strict Checks
Related Configuration
- Astro Configuration - Build and server settings
- CSS Variables - Styling configuration
- Package Dependencies - npm packages and versions
Best Practices
- Use strict mode: Helps catch bugs early in development
- Define prop interfaces: Always type component props
- Avoid ‘any’ types: Use specific types or ‘unknown’ instead
- Check before deployment: Run
astro checkin CI/CD pipeline - Keep types updated: Regenerate
.astro/types.d.tswhen content changes
Troubleshooting
Types not updating
Solution: Restart the dev server to regenerate type definitions:Editor not recognizing Astro types
Solution: Install the Astro VS Code extension:Type errors in .astro files
Solution: Ensure.astro files are in the src directory and the dev server is running to generate types.