Skip to content

Instantly share code, notes, and snippets.

@dewey92
Last active August 9, 2019 08:03
Show Gist options
  • Save dewey92/111b4de8f94260bbbda66589af3b110a to your computer and use it in GitHub Desktop.
Save dewey92/111b4de8f94260bbbda66589af3b110a to your computer and use it in GitHub Desktop.
// brand.ts
// use symbol, but don't export it!
declare const _brand: unique symbol;
export type Brand<Name, Type> = Type & { [_brand]?: Name }
// degree-module.ts
export type Celcius = Brand<'Celcius', number>;
export type Fahrenheit = Brand<'Fahrenheit', number>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment