Skip to main content
Sonamu projects are written in TypeScript, with API and Web each having independent 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

moduleResolution: β€œbundler”
  • Uses bundler mode instead of Node.js’s node mode
  • Matches how Vite and esbuild resolve modules
  • Supports package.json’s exports field
Using moduleResolution: "node" may conflict with Vite.

Extended Configuration Files

Sonamu API uses additional tsconfig files for code generation.
api/tsconfig.schemas.json
Purpose:
  • Generate sonamu.generated.ts file
  • Generate Entity schema types
  • Convert DB schema β†’ TypeScript types
When Used:
api/tsconfig.types.json
Purpose:
  • Generate API response types
  • Define Request/Response types
  • Share types with frontend
When Used:

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

You can import with absolute paths:
See Path Mapping for details.

Running Type Checks

During development, --watch mode is recommended for real-time type checking.

Common Troubleshooting

Symptoms:
Cause:
  • node_modules not installed
  • Incorrect import path
Solution:
Symptoms:
Cause:
  • experimentalDecorators is disabled
Solution:
Symptoms:
Cause:
  • jsx option not configured
Solution:
Required for React 17+
Symptoms:
Cause:
  • paths configuration missing
  • baseUrl configuration needed
Solution:
Vite configuration also needed:
vite.config.ts

Customization

Additional Library Types

Stricter Checks

These options may cause compatibility issues with existing code.

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