Last active
August 9, 2019 08:03
-
-
Save dewey92/111b4de8f94260bbbda66589af3b110a to your computer and use it in GitHub Desktop.
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
// 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