Open this example in the interactive library
Source code
type Brand<T, Name extends string> = T & { readonly __brand: Name };
console.log(
((v: number) =>
Number.isSafeInteger(v) ? (v as Brand<number, "Cents">) : null)(19.5),
);
Sample output
null
