Discriminated unions use a literal property (like type) to label each variant. A switch or equality check on that field narrows to the right shape. This is handy when you want a common "view model" regardless of the original variant.
type U = { type: "user"; username: string } | { type: "org"; orgName: string };
// Check u.type and build a common { label } object
Return a small object rather than a string to keep data flexible.
Produce a unified header object from different entity shapes.