The underlying value type to be branded
String literal keys that will be marked as true in the brand
String literal keys that will be marked as false in the brand (defaults to never)
// Create distinct ID types
type UserId = Brand<string, 'UserId'>;
type PostId = Brand<string, 'PostId'>;
// These are incompatible even though both are strings
const userId: UserId = "user123" as UserId;
const postId: PostId = "post456" as PostId;
// const wrongAssignment: UserId = postId; // Error!
// Create validated types
type NonZeroInt = Brand<number, 'integer', 'zero'>;
Creates a branded type (nominal type) to distinguish values at the type level. Branded types prevent accidental type compatibility even when the underlying types are the same.