clean-jsdoc-theme TypeDoc APIv0.0.0

Brand

Brand<T, Brand extends string> = T & { __brand: Brand }

Source: common.ts:368

Branded/tagged type for nominal typing

Type Parameters

  • T — Base type
  • Brand extends string — 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