Skip to content
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

Support jstype overrides #37

Merged
merged 2 commits into from
Feb 11, 2019

Conversation

luk3thomas
Copy link
Contributor

This PR should address the issues mentioned in #10.

If I add the [jstype=JS_STRING] option to a message then the generated stubs will return a string for the 64-bit integer value. The generated typescript definition does not handle this.

I didn't see any tests, but I did give my changes a go and I'm getting the results I expected.

event.proto

message Event {
  fixed64 id = 1 [jstype = JS_STRING];
}

Generated interface

 export class Event extends jspb.Message {
-    getId(): number;
-    setId(value: number): void;
+    getId(): string;
+    setId(value: string): void;

     getGeneratedAt(): number;
     setGeneratedAt(value: number): void;
@@ -272,7 +272,7 @@ export class Event extends jspb.Message {

 export namespace Event {
     export type AsObject = {
-        id: number,
+        id: string,
         generatedAt: number,
         receivedAt: number,
         sourceId: number,

Fixes #10

@luk3thomas luk3thomas force-pushed the support-jstype-overrides branch from 3cc2b20 to 323e450 Compare January 12, 2019 20:48
@luk3thomas luk3thomas force-pushed the support-jstype-overrides branch from 323e450 to c379f1f Compare January 12, 2019 20:53
@luk3thomas luk3thomas force-pushed the support-jstype-overrides branch from c379f1f to 5881b1a Compare January 12, 2019 20:58
@agreatfool
Copy link
Owner

That's awesome. Thanks for the pr.

I'm a bit busy these days. Please give me several days to merge it. Thanks.

@agreatfool agreatfool merged commit 4e86331 into agreatfool:master Feb 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handling (de)serialization modes for 64-bit integer types
2 participants