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

map<string, google.protobuf.Timestamp> produces invalid fromJson and fromPartial code #99

Closed
mscolnick opened this issue Jul 15, 2020 · 3 comments

Comments

@mscolnick
Copy link
Contributor

If this was added to SimpleWithMap

message SimpleWithMap {
  map<int32, Entity> entitiesById = 1;
  map<string, string> nameLookup = 2;
  map<int32, int32> intLookup = 3;
+ map<string, google.protobuf.Timestamp> mapOfTimestamps = 4;
}

The output will generate the map entry to be Date.fromJSON and Date.fromPartial:

export const SimpleWithMap = {
fromJSON(object: any): SimpleWithMap {
  ...
  if (object.mapOfTimestamps !== undefined && object.mapOfTimestamps !== null) {
    Object.entries(object.mapOfTimestamps).forEach(([key, value]) => {
      message.mapOfTimestamps[key] = Date.fromJSON(value); // Property 'fromJSON' does not exist on type 'DateConstructor'
    })
  }
  return message;
},

fromPartial(object: DeepPartial<SimpleWithMap>): SimpleWithMap {
  ...
  if (object.mapOfTimestamps !== undefined && object.mapOfTimestamps !== null) {
    Object.entries(object.mapOfTimestamps).forEach(([key, value]) => {
      if (value !== undefined) {
        message.mapOfTimestamps[key] = Date.fromPartial(value); // Property 'fromPartial' does not exist on type 'DateConstructor'
      }
    })
  }
  return message;
},
}
@stephenh
Copy link
Owner

Hm, thanks for the report and great repro. I'll poke around when I get a chance...

@stephenh
Copy link
Owner

Well, it took awhile to get a weekend hack morning on this, but this will be fixed in the next release. Thanks for the report!

@mscolnick
Copy link
Contributor Author

amazing, thank you very much!

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

No branches or pull requests

2 participants