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
Been using connect-web for some time, it's sooo good compared to the past JS/TS generators I've used. Thanks so much for the work!
I was wondering if the documentation could add a few words on how best to use the generated definitions.
For example, what are the intended uses for PartialMessage<T> and PlainMessage<T>? What's the best practice for class conversions and initialization? I ask because, for example, the default constructor's parameter PartialMessage has insufficient IDE support and shows no auto-complete when initializing. The FieldList helps with type-checking but it's not too clear if it's intended for the users or for internal use.
The documentation already covered how to convert to/from JSON and binary; a few more documentation examples on which interface/class/functions to use for type-checking during conversions to/from other user types will be very much appreciated!
The text was updated successfully, but these errors were encountered:
I think something is off with your IDE. The TypeScript language service should absolutely be able to provide auto-complete and suggestions:
Maybe you need to update TypeScript, or some part of your IDE? This should definitely work!
Thanks for your questions regarding initialization! If you want to create a new instance of a message, you should always use new, and pass the properties where you want to provide a value. This makes sure that other properties - for example map fields, repeated fields and scalar fields - always have their default value. You can find more information here and here.
We use PartialMessage<T> for the initializer object of constructors - it simply makes all properties optional. In your code, you should only use PartialMessage<T> if you provide an API for other users, and want to give them the most flexibility for passing in data.
PlainMessage<T> is an exact representation of just the fields of a message, without any of its methods. You can find more information here. This type can be useful in you business logic, if you don't care about the class methods for serialization, and don't need instanceof. Note that we are going to improve this part soon, see bufbuild/protobuf-es#230 (comment).
I am sorry our connect.build documentation wasn't more helpful. I think we do have some hopefully helpful documentation on protobuf-es, but we definitely need to integrate it better with connect.build. I've bumped the priority of our internal ticket for this. Thanks for your input!
Been using connect-web for some time, it's sooo good compared to the past JS/TS generators I've used. Thanks so much for the work!
I was wondering if the documentation could add a few words on how best to use the generated definitions.
For example, what are the intended uses for
PartialMessage<T>
andPlainMessage<T>
? What's the best practice for class conversions and initialization? I ask because, for example, the default constructor's parameter PartialMessage has insufficient IDE support and shows no auto-complete when initializing. TheFieldList
helps with type-checking but it's not too clear if it's intended for the users or for internal use.The documentation already covered how to convert to/from JSON and binary; a few more documentation examples on which interface/class/functions to use for type-checking during conversions to/from other user types will be very much appreciated!
The text was updated successfully, but these errors were encountered: