Course lesson

Create and Effectively Use TypeScript Brand Types

Type utilities are essentially functions for our types in TypeScript. We'll create a type utility named Brand that will accept a primitive type and the name of the brand.

Duration
3 min
Access
Free
Transcript
Retained from source evidence

Type utilities are essentially functions for our types in TypeScript. We'll create a type utility named Brand that will accept a primitive type and the name of the brand.

This will allow us to easily create Brand types throughout our application like the following:

type Email = Brand<string, "EMAIL">;
type DateString = Brand<string, "DATE_STRING">

Email and DateString are both strings at the end of the day but you cannot assign a DateString to an Email or visa versa.