-
Notifications
You must be signed in to change notification settings - Fork 343
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
Write null instead of undefined #869
Write null instead of undefined #869
Comments
I was just about to open an issue and I saw this! This is a must-have in my opinion. In my company we all work with null types since undefined can thrown in some cases, Working with null is more convenient to know if it was the developer's intention or unknown. From my searching, there have been multiple issues about it, what do you say @stephenh :p |
Is the idea that if Fwiw normally in non-protobuf/JSON APIs, I like to use That said, protobuf doesn't have a way to differentiate these two on the wire, so that null-is-unset / undefined-is-omit convention is (unfortunately imo) not applicable to protobuf APIs. Granted, Firestore and other "null is just our preferred convention" is fair, but personally not something I'll work on. If you'd like to submit a PR, and the PR is not huge, I'd consider accepting it as yet-another-flag...that said, I'm worried such a fundamental change is going to be a lot of complications to the codebase, but who knows, maybe not. |
Changes: - with this flag, undefined types will be replaced with null. - fields with optional label in proto files, will implicitly accept undefined too. this feature is needed when we wanna have better type alignment with ORMs ( drizzle, typeorm, prisma ) or other services such as Firestore, since they mostly ignore `undefined` in their types. Note: @stephenh as you wanted I made simple, small changes, this works well for my `nestjs` project, I'm not very familiar with other implementations and frameworks, please check it out and let me know what you think. if any changes are required please let me know, I will work them out. thanks for this amazing library 🙏 closes #869
🎉 This issue has been resolved in version 1.171.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
A good option to implement can be the possibility to compare with null instead undefined. This is useful when dealing with Firestore, which skips undefined properties and can generate issues when sorting.
The text was updated successfully, but these errors were encountered: