Created
January 11, 2024 00:00
-
-
Save juliencrn/8eb11f115429c67e45465d3109c488e9 to your computer and use it in GitHub Desktop.
Branded type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://egghead.io/blog/using-branded-types-in-typescript | |
// In its own module (file) to keep `Brand` private | |
declare const __brand: unique symbol | |
type Brand<B> = { [__brand]: B } | |
export type Branded<T, B> = T & Brand<B> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment