Type aliases
Brand
Brand<
T
,TBrandName
> =NominalType
<"brand"
,TBrandName
> &T
Use this to produce a new type that satisfies the original type, but not the other way around. That is to say, the branded type is acceptable wherever the original type is specified, but wherever the branded type is specified, the original type will be insufficient.
You can use this to create specialized instances of strings, numbers, objects, and more which you would like to assert are special in some way (eg. numbers that are non-negative, strings which represent the names of foods, objects that have passed validation).
Type Parameters
Type Parameter | Description |
---|---|
T | The base type to brand |
TBrandName extends string | A string that identifies a particular brand. Branded types with identical names will satisfy each other so long as their base types satisfy each other. Branded types with different names will never satisfy each other. |