Create and Use TypeScript Branded Types

Published: 16 July 2024
on channel: egghead.io
179
5

Lesson by Tomasz Ducin. Check out his content on egghead here: https://egghead.io/q/resources-by-tom...

This lesson is a part of Tomasz's upcoming course, "Domain Data Modelling using TypeScript Aliases, Brand Types and Value Objects"

Branded types are useful when you have data that shares the same primitive type, but the way its shaped makes it so that it can only be used in its own contexts.

For example, both emails and date strings are string primitives but the context they're each used in contexts incompatible with the other.

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.


Watch video Create and Use TypeScript Branded Types online without registration, duration hours minute second in high quality. This video was added by user egghead.io 16 July 2024, don't forget to share it with your friends and acquaintances, it has been viewed on our site 17 once and liked it people.