Comments (4)
let a = new SearchRequest();
a.result_per_page = "1111111"
// a.page_number = 1111111
console.log(a);
let b = SearchRequest.deserializeBinary(a.serializeBinary());
console.log(b);
from protoc-gen-ts.
I couldn't understand the question but from what you wrote I think you want to be able to create proto messages through an helper function. But this plugin does not generate any generic helper function to create proto messages. Instead, it generates a method in every single proto message. The method called as deserialize (similar to decode) and you can pass your unit8array to deserialize method in the particular message and could get the constructed (filled) message.
All you need to do is write a statement like this
MyProtoMessage.deserialize(new Uint8Array())
This statement will return an instance of MyProtoMessage that populated with the data you have passed in.
I hope this is clear for you.
Also, since the all proto messages have a deserialize method, you can write a generic helper function to construct as you wish.
from protoc-gen-ts.
@GeTOUO Do you still have any questions in your mind?
from protoc-gen-ts.
I'm going to close this issue as resolved. Please feel free to reopen.
from protoc-gen-ts.
Related Issues (20)
- Cannot deserialize maps with empty K/V encoded by other language implementations HOT 2
- migrate from rules_nodejs to rules_js HOT 2
- Make it possible to opt-out of grpc service generation HOT 1
- Server streaming rpc is broken HOT 4
- Solo enum in the proto file case a bad field type name HOT 3
- Unable to make grpc-js example work HOT 2
- Feature Request: Simple type vaildate for `fromObject` HOT 1
- fromObject does not check for nullables when mapping HOT 3
- Make this repo available on registry.bazel.build?
- How to resolve the 'TypeError: Invalid arguments' error when converting a code with protoc HOT 1
- Imported package name / namespace only partially removed
- bug: Can't compile due to name conflicts in some cases HOT 1
- Typescript 5 breaking compilation HOT 9
- no_namespace is causing invalid typescript to be generated HOT 3
- Cannot use in bazel project as no BUILD file HOT 2
- Updated protoc-gen-ts to version 0.8.5 and TypeScript to version 5.0.3 but still getting "--ts_out: protoc-gen-ts requires TypeScript 4.9 or above." HOT 7
- Is It Possible to Expose Request/Response Types for Service Method Definitions
- How can I get type of message in Typescript HOT 2
- Directly include generated ts file as dependency in ts_project HOT 1
- fromObject(toObject()) is not working correctly for oneof fields 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 protoc-gen-ts.