Course lesson
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.
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.
Course lesson
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.