Skip to content

Instantly share code, notes, and snippets.

@juliencrn
Created January 11, 2024 00:00
Show Gist options
  • Save juliencrn/8eb11f115429c67e45465d3109c488e9 to your computer and use it in GitHub Desktop.
Save juliencrn/8eb11f115429c67e45465d3109c488e9 to your computer and use it in GitHub Desktop.
Branded type
// 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