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
It is quite annoying and tedious that a oneofs fields do not default to being optional as it triggers typescripts type safety. However, it could easily be fixed if optionals were used by default for a oneofs fields without needing to enable the useOptionals option, as it also allows other fields to be optional.
Hm, yeah, @Larkooo I'd generally recommend using the oneof=unions option, which should probably be the default, but in the case of oneof=unions not being in use, having optional keys for oneof properties seems reasonable. If you want to work on a PR, that'd be great.
It is quite annoying and tedious that a oneofs fields do not default to being optional as it triggers typescripts type safety. However, it could easily be fixed if optionals were used by default for a oneofs fields without needing to enable the useOptionals option, as it also allows other fields to be optional.
We could perhaps extend the useOptionals option to only allow oneofs fields to be optional or just check if the property is within a oneof and directly make it optional
https://github.com/stephenh/ts-proto/blob/main/src/main.ts
ts-proto/src/types.ts
Line 340 in b90821d
The text was updated successfully, but these errors were encountered: