-
Notifications
You must be signed in to change notification settings - Fork 348
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
feat: extensions #808
feat: extensions #808
Conversation
I hope you like the way I implemented it, if you want any changes let me know. One possible problematic area of note is that the code parses both packed and unpacked extensions, and packed is always parsed before the unpacked, leading to possible re-ordering. If I remember correctly, protobuf's website said that applications should not expect field order to be preserved, so it shouldn't be a problem. ts-proto-decriptors should be updated to add extensions |
Any thoughts on this? |
Hey @davidzeng0 ; from my initial scan of the tests, it looks pretty great, very standard approach to protobuf extensions AFAIU (I've not actually used them personally before). It'll probably be the weekend before I dive in a bit more, but its great to have this feature. Thank you! |
Alright 👍 |
Rebased and fixed tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great!
Awhile ago I'd thought about maybe trying to figure out an alternative API to the stock Extension.set(message, someConst, value)
, like something like:
const message = ...
const extended = Extension.wrap(message)
extended.someField = 1
extended.otherField = 2
But I don't think that's even possible b/c the proto file doesn't even have a name for what the wrapped type would be, i.e. something like:
extension MyNiceName extends Extendable {
string someField = 1
}
Would let us know to use MyNiceName
as the type name for all of the someField
/ etc. fields ... but that is just not there/something they thought to include in the proto file. 🤔 So 🤷 I think that puts a damper on any cute/alternative APIs.
# [1.146.0](v1.145.0...v1.146.0) (2023-04-01) ### Features * extensions ([#808](#808)) ([f956128](f956128))
🎉 This PR is included in version 1.146.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Thanks for being patient with me :) |
A ts-proto-descriptors bump with outputExtensions=true would be great |
ts-proto-descriptors bump: #814 |
Can be automatically merged