Brand
Brand<T, Brand extends string> = T & { __brand: Brand }Source: common.ts:368
Branded/tagged type for nominal typing
Type Parameters
T— Base typeBrandextendsstring— Brand identifier
Example
CODE
type UserId = Brand<string, 'UserId'>
type OrderId = Brand<string, 'OrderId'>
const userId: UserId = 'user-123' as UserId
const orderId: OrderId = 'order-456' as OrderId
// userId = orderId // Error! Types are incompatible