Brand Types
gglib packages reach for these brand type utilities to make things more typesafe but also to avoid typescript enums
ts
import { brand, Brand } from '@gglib/utils'
type Channel = Brand<string, 'Channel'>
const Channel = {
Red: brand<Channel>('red'),
Green: brand<Channel>('green'),
Blue: brand<Channel>('blue'),
}
function typedFunction(channel: Channel) {
console.log(channel)
}
typedFunction(Channel.Red)
typedFunction(Channel.Green)
typedFunction(Channel.Blue)