Strict Typing
In FRAME, strict typing with TypeScript is a fundamental rule. We believe errors should be caught at compile and development time, not in production.
What Does Strict Typing Mean?
Section titled “What Does Strict Typing Mean?”It means that data types and schemas flow continuously and safely from the persistence layer (Database) to the user interface, passing through the backend (API).
- Database (Drizzle ORM): Models are defined using Drizzle ORM in
@frame/models. Drizzle automatically infers Zod schemas and TypeScript types for our tables. - Validation (Zod): We use Zod to create validation schemas based on Drizzle models. This gives us runtime type safety for data at many points in the system: frontend forms, backend requests and responses, and more.
- API (NestJS): In
apps/nest, routes consume and return types generated from our models and schemas, using strongly typed DTOs. - Client (Next.js / Astro): On the frontend, we consume the same types and schemas defined in shared packages. If a field changes in the database, the client immediately raises a compile error.
Benefits
Section titled “Benefits”- Context for AI: AI can run TypeScript to detect and correct errors during development.
- Safe Refactoring: Renaming a column in the database immediately highlights errors at every point where the models are used.
- Error Reduction: Most format or data-type errors are detected and fixed before the code is merged to production.