tsconfig.json files. They use configurations optimized for their respective environments.
Project Structure
my-project/ - api/ - tsconfig.json # API server configuration - tsconfig.schemas.json # Schema
generation - tsconfig.types.json # Type generation - web/ - tsconfig.json # React app
configuration - tsconfig.node.json # Vite configuration
API and Web are independent TypeScript projects. Their configurations are separate.
API Server Configuration
Base tsconfig.json
api/tsconfig.json
Key Options Explained
- Module Settings
- Decorators
- Strict Mode
- Additional Checks
- Uses bundler mode instead of Node.jsβs
nodemode - Matches how Vite and esbuild resolve modules
- Supports
package.jsonβsexportsfield
Extended Configuration Files
Sonamu API uses additional tsconfig files for code generation.tsconfig.schemas.json - Schema Generation
tsconfig.schemas.json - Schema Generation
api/tsconfig.schemas.json
- Generate
sonamu.generated.tsfile - Generate Entity schema types
- Convert DB schema β TypeScript types
tsconfig.types.json - Type Generation
tsconfig.types.json - Type Generation
api/tsconfig.types.json
- Generate API response types
- Define Request/Response types
- Share types with frontend
Web (React) Configuration
web/tsconfig.json
Differences from API
API uses
moduleResolution: "bundler" (lowercase), Web uses moduleResolution: "Bundler"
(uppercase). Both make Vite resolve modules in bundler mode.Path Mapping
Running Type Checks
- API
- Web
- All
Common Troubleshooting
Cannot Find Module
Cannot Find Module
Symptoms:Cause:
node_modulesnot installed- Incorrect import path
Decorator Error
Decorator Error
Symptoms:Cause:
experimentalDecoratorsis disabled
JSX Error (Web)
JSX Error (Web)
Symptoms:Cause:Required for React 17+
jsxoption not configured
Path Mapping Not Working
Path Mapping Not Working
Symptoms:Cause:Vite configuration also needed:
pathsconfiguration missingbaseUrlconfiguration needed
vite.config.ts
Customization
Additional Library Types
Stricter Checks
include/exclude Patterns
Next Steps
Type Checking
Learn about Strict mode and type check options
Path Mapping
Configure absolute path imports
Defining Entities
Define Entities
API Types
Define API request/response types