Comments (2)
Protobuf 3 cannot distinguish between unset fields and zero fields. The zero value is not sent on the wire.
from ts-proto.
Hi @biljecki ; unfortunately @paralin is right and this is just a fact of life with protobuf, that optional handling is really suboptimal/all over the place.
Per the arrays, I glanced at a fromJSON
in our integration/simple
directory and it is setting the array to []
:
fromJSON(object: any): Simple {
return {
name: isSet(object.name) ? globalThis.String(object.name) : "",
age: isSet(object.age) ? globalThis.Number(object.age) : 0,
createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined,
child: isSet(object.child) ? Child.fromJSON(object.child) : undefined,
state: isSet(object.state) ? stateEnumFromJSON(object.state) : 0,
grandChildren: globalThis.Array.isArray(object?.grandChildren)
? object.grandChildren.map((e: any) => Child.fromJSON(e))
: [],
And the type of grandChildren
is []
.
As you can tell, many others have disliked proto3's optional behavior, and we have ~more than a few options for attempting to make them not suck, but there are pros/cons to each.
Happy to see doc/bug fix PRs if you have very specific behavior that needs improved/fixes bug, but otherwise I'm going to close this out. Thanks!
from ts-proto.
Related Issues (20)
- removeEnumPrefix not working HOT 1
- fromJSON should accept both snake_case and camelCase keys HOT 1
- Provide Options type for execution in TS HOT 1
- Add common types to their own file/export w/outputIndex option HOT 2
- Support `google.api` attributes/conventions HOT 1
- NestJS without Observables HOT 1
- meta generated for messages with oneOf properties is incorret for other properties HOT 1
- Add types for toJSON/fromJSON methods HOT 1
- TypeError on Runtime ChannelCredentials object HOT 1
- Using 'useDate=string' parameter; the response is still anticipating an object for Timestamp Wrapper
- Encode crashes on `null` object values HOT 2
- Rpc doesn't account for metadata HOT 2
- Rpc is not exported by ts-proto as it previously was HOT 6
- Generated affixes HOT 1
- Conflicting protobuf definitions when using ts-proto plugin with Buf HOT 2
- Support for proto-loader "virtual" oneof field
- Release updated ts-proto-descriptors? HOT 4
- Proto import statements not being recognized HOT 1
- Support for messages with the same name as an rpc method HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ts-proto.