-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create raw data types as well #1058
Comments
We didn't anticipate the dislike for There is an alternative, though: The source code of protoc-gen-es is pretty compact, considering that it generates enums, types, descriptors, and JSON types. If you pick just the code to generate message types, it should be less than 500 lines of code. So my suggestion would be to create such a plugin, and give it a try. If it works out well, you could publish it for others to use. |
@timostamm It is unfortunate that some folks dislike Perhaps I wasn’t clear initially. I have no interest in removing The type I’m looking for is already generated by The change is straightforward -- I’ve submitted #1060 showcasing one way of doing it. I don’t see how this could be a breaking change, and as far as I can tell, all project tests pass with the modification. Side note: I do think it would be more correct if |
In my case, I'd like to create a function like : // user.proto
syntax = "proto3";
package example;
message User {
string id = 1;
} // index.ts
function createMyThingByUser(user: User) {
// ...
} But the const userId = 1;
createMyThingsByUser(create(UserSchema, { id: userId })); I totally agree with what @abalmos said ( |
Going to mark this issue as closed since we do not have any plans to introduce a new type like what was requested. The Anyone who is ok with the tradeoffs, can write a custom code generation plugin to generate exactly what they want, as mentioned in #1058 (comment). |
@nicksnyder These types would export as different files, yeah? I couldn't see a way to do it otherwise. While It is rather unfortunate that the project does not seem interested in user feedback. |
I was triaging issues with @timostamm this morning and was trying to be helpful by providing an update that we aren't optimistic about this making sense to do, but in retrospect I clearly made a mistake here in closing this issue before more discussion happened. I am sorry! I am going to re-open this for now and @timostamm can share more detailed thoughts about the potential consequences of exposing a separate type. We do very much care about user feedback (and the API) and I am sorry I gave the impression otherwise. There are many tricky issues to navigate when it comes to being true to the semantics of Protobuf while providing the best API/devex possible and being mindful of performance all at the same time. |
Currently a separate type via I think we end up with a solution that does not add any new typings but achieves what is being requested both in this discussion and #1062. |
will produce something like
However, the
User
type is hard to use when working with the message body as data throughout the code based because of the $typeName and $unknown fileds thatMessage<"example.User">
adds. What if instead it generated something like:So that
UserRaw
can be used to hold data in the program logic, but one can also easily do:This would remove the need for using a helper like
OmitTypeName
all over the place.The text was updated successfully, but these errors were encountered: