← All Exercises
Branded Types for Nominal Typing
advancedtypescript
Background
Branding adds a unique type-level marker to create nominal typing in TypeScript structural type system.
Problem
Create branded types for Email and UserId that are structurally strings but nominally distinct, preventing accidental mixing.
Input
Strings that should be branded as specific domain types.
Output
Branded string types that cannot be accidentally mixed.
Sample tests
Your solution
Learning objective
Learn branded types for nominal type safety in TypeScript structural type system.