Open this example in the interactive library
Source code
type Brand<T, Name extends string> = T & { readonly __brand: Name };
console.log(
((a: Brand<number, "CAD">, b: Brand<number, "CAD">) =>
(a + b) as Brand<number, "CAD">)(
20 as Brand<number, "CAD">,
5 as Brand<number, "CAD">,
),
);
Sample output
25
