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