Types
Beginner
Everyday Types for Enterprise Data
Model request payloads, database rows, DTOs, and UI view models with clear everyday TypeScript types.
34 min
3 sections
objects
arrays
unions
dto
1
2
3
01. Primitive Types That Matter
Section 1 of 3
Most enterprise bugs are not solved by advanced type tricks. They are solved by consistently typing IDs, money, dates, booleans, and external payloads. Use primitives deliberately and promote important primitives into domain types when they carry business meaning.
typescript
type InvoiceStatus = "draft" | "sent" | "paid" | "void";
type InvoiceSummary = {
id: string;
customerId: string;
status: InvoiceStatus;
totalCents: number;
dueDateIso: string;
isOverdue: boolean;
};
const summary: InvoiceSummary = {
id: "inv_1001",
customerId: "cus_42",
status: "sent",
totalCents: 254900,
dueDateIso: "2026-07-31",
isOverdue: false,
};Exercise
Type a customer account summary
Practice
Create a type for a customer account card with id, legal name, plan, seats used, seat limit, renewal date, and risk level.
Back to Course