type UserId = string & { readonly __brand: 'UserId' }
function createUserId(id: string): UserId {
return id as UserId
}A branded type uses an intersection with a phantom property to distinguish nominally equal types.
A branded type adds a phantom property to distinguish types that share the same underlying representation.
Challenge: Implement createUserId(id) that casts a string to UserId.
type UserId = string & { __brand: 'UserId' }
createUserId('user-1') // β 'user-1' (as UserId)