Skip to content

Instantly share code, notes, and snippets.

@dewey92
Last active October 9, 2018 13:01
Show Gist options
  • Select an option

  • Save dewey92/b081b1e39c53c06f728805304cf3e7eb to your computer and use it in GitHub Desktop.

Select an option

Save dewey92/b081b1e39c53c06f728805304cf3e7eb to your computer and use it in GitHub Desktop.
Branding improvement
type Brand<Name, Type> = Type & { _brand?: Name } // optional
type Celcius = Brand<'Celcius', number>;
type Fahrenheit = Brand<'Fahrenheit', number>;
const fiveC: Celcius = 5; // typechecked :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment