CodeZettaInterview Hub

TypeScript · Advanced Types · Fresh / Intern · Live Coding

What is a branded/nominal type pattern?

Short Interview Answer

Intersect with unique brand to prevent mixing compatible primitives (UserId vs OrderId).

Detailed Explanation

Zero-runtime cost with casting at boundaries. Improves domain safety.

Example

type UserId = string & { readonly __brand: 'UserId' };

Did you know this answer?