You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a discriminated union is defined, for example:
typePaymentMethod= Card ofCreditCard
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:
typePaymentMethod= Card ofCardDetails:CreditCard
The text was updated successfully, but these errors were encountered:
When a discriminated union is defined, for example:
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:
The text was updated successfully, but these errors were encountered: