A flavoured type is a variation on branded types.
type WeakUuid = string & {
_type?: "@safelytyped/uuid";
}
type WeakCombUid = string & {
_type?: "@safelytyped/combuid";
}
The difference between branded types and flavoured types is that flavoured types make the _type
property optional.
Why do we do that? Isn't it much less robust?
They were invented to help with unmarshalling data from a database or equivalent. See this blog post for more details.