Explain 'Branded Types' for Domain-Driven Design (DDD).
Updated May 4, 2026
Short answer
Branded types (or 'Flavoring') allow you to distinguish between identical primitive types at the type level to enforce domain rules.
Deep explanation
In DDD, a UserId and an AccountId shouldn't be interchangeable just because they are both strings. TypeScript's structural typing would normally allow this. Branding involves intersecting a primitive type with a unique 'tag' object. This forces the developer to explicitly cast or validate a string before it can be used as a specific domain ID, preventing logic bugs where the wrong ID is passed to a service.
Unlock with a Pro subscription to view this section.
View pricingReal-world example
No real-world example available yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProCommon mistakes
No common mistakes listed yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProFollow-up questions
No follow-up questions available yet.
Unlock with a Pro subscription to view this section.
Upgrade to Pro