Description
When a discriminated union is defined, for example:
type PaymentMethod = Card of CreditCard
The compiler automatically creates a property named Item for the Card case. The issue is, for situations where we rely heavily on serialization, these automatically generated names are both dangerous and impractical.
In our case, we typically serialize DUs 1) to store a record in the database, and 2) to send the record to the typescript front-end. For this later case in particular, wrapping client-side types in properties named "item", is terrible.
Unfortunately, these situations may be spotted too late if our code does not use some piece of data immediately. And once an automatically generated field name is stored in the production DB, making the change is a much higher cost endeavour.
Thus my proposal to add a rule requiring developers to give explicit name field names to DU cases, such as:
type PaymentMethod = Card of CardDetails: CreditCard