What is a ‘branded type’ (nominal type) pattern in TypeScript and why is it used?

TypeScript Professional Medium

TypeScript Professional — Medium

What is a ‘branded type’ (nominal type) pattern in TypeScript and why is it used?

Key points

  • Branded types prevent accidental interchangeability of shapes
  • Intersection with a unique symbol or string literal creates a distinct type
  • Nominal typing is achieved through this pattern
  • Helps enforce stricter type checking in TypeScript

Ready to go further?

Related questions