How can I kind of narrow down the usages in the code of a string that can hold any value but has a semantic. E.g. a special ID or an email.
E.g. something like that:
type EMail = string;
type OrderID = string;
getUserEmail(): EMail;
getOrderById(id: OrderID): Order;
I can declare types but this still compiles:
getOrderById(getUserEmail()); // Does not throw a compiler error.
Is there a way to enforce that this is not possible?