Brand
Brand
import { Brand } from 'funkcia/brand';
type UserId = Brand<string, 'UserId'>;
type ProductId = Brand<string, 'ProductId'>;
const userId ='user_123' as UserId;
const productId = 'product_456' as ProductId;
declare function getUser(id: UserId): User | null;
getUser(userId); // OK
getUser(productId); // Type error: ProductId is not assignable to UserIdBrand.of
Without validation
With validation
Brand.unbrand
Brand types
Brand.Unbrand
Last updated
Was this helpful?