Branded types#

typescript
type UserId = string & { __brand: 'UserId' };
type OrgId  = string & { __brand: 'OrgId' };
// Now you can't pass an OrgId where a UserId is expected.

Three patterns that pay rent: satisfies, exhaustive never checks, and branded primitives.