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
This can be really difficult to deal with in code, because the name of the property depends on the value of $case. For example:
switch (v.$case) {
case "float":
case "double":
// I can't write generic code to handle both, because one is accessed with v.float, while the other is v.double!
break;
case "int32":
console.log(v.int32.whatever);
break;
}
This also inspired a lot of the complex type helpers I use (see #1034).
Today, if I enable
oneof=union
, my union might generate code like this:This can be really difficult to deal with in code, because the name of the property depends on the value of
$case
. For example:This also inspired a lot of the complex type helpers I use (see #1034).
A nicer codegen would be:
Which then allows:
This would have to be a new option to avoid breaking previously generated code.
The text was updated successfully, but these errors were encountered: