Closed ff-ils closed 9 months ago
So the question is to generate google.protobuf.Int32Value field = 1
as field?: number
?
Yes, we want to do that. I'm closing this as a duplicate of https://github.com/timostamm/protobuf-ts/issues/181, but thanks for bringing it up.
Unfortunately, we can't implement this yet. We need to switch our code generator to use @bufbuild/protoplugin under the hood first, so that we have more flexibility in the plugin. There hasn't been much activity on that work lately, but it's still the best way forward.
It would possible to add a switch to handle in a different way google wrapper types, to map them to base types, like when using optional keyword? It would be not compliant, but the use case is this: in c#, if a field is "optional int32" it becomes an "int" instead of "int?", while in TypeScript it is (correctly) "number | undefined". The only way to have an "int?" on the c# side is to use google.protobuf.Int32Value, but on TypeScript side it is no more a base type.
So now you have to choose between
| c# | TypeScript |
| int | number? |
| int? | google.protobuf.Int32Value |
The request is to add a switch to handle wrapper types as if defined as "optional" with a base type, to have "int?" <--> "number?".