What problem does it solve?
This guide provides a structured blueprint for building TypeScript type definitions that map API shapes to strongly typed models, enabling safer, more maintainable code across src/types.
- It ensures API snake_case fields align with TypeScript types, supports form-oriented shapes, and defines union types for statuses and enums, all to reduce duplication and errors when modeling domain data such as Contact, Address, Lead, Column, and User.
- It also demonstrates patterns for generic component props and nested/complex types to improve reusability and scalability in large codebases.
Core Features & Use Cases
- API Data Models: snake_case API fields mapped to TypeScript types with optional fields clearly marked.
- Form Oriented Types: separate Form types derived from API models to optimize for validation and submission.
- Union & Generic Patterns: literal unions for statuses and generic Column<T> definitions for reusable UI components.
- Domain Patterns: reusable templates for ContactType, AddressType, LeadType, ColumnType, UserType, TabsType, with examples in discussions of API mapping, forms, and components.
- Export Strategy: guidance on barrel exports and module boundaries to keep types discoverable.
Quick Start
Start by defining an API model in src/types, then create a corresponding form type and a status union to enable end-to-end type safety.