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 with value as google wrapper type produces invalid fromJSON and fromPartial code #182

Closed
cburbank opened this issue Jan 13, 2021 · 2 comments · Fixed by #370
Closed
Labels

Comments

@cburbank
Copy link

cburbank commented Jan 13, 2021

This seems to be related to #99 but applies to Google "wrapper" types. For example, the following message:

message MyMessage {
    map<int64, google.protobuf.StringValue> map_of_stringvalues = 1;
}

Produces output that uses string.fromJSON and string.fromPartial

fromJSON(object: any): MyMessage {
  const message = { ...baseMyMessage } as MyMessage;
  message.mapOfStringvalues = {};
  if (object.mapOfStringvalues !== undefined && object.mapOfStringvalues !== null) {
    Object.entries(object.mapOfStringvalues).forEach(([key, value]) => {
      message.mapOfStringvalues[Number(key)] = string.fromJSON(value);
    })
  }
  return message;
},
fromPartial(object: DeepPartial<MyMessage>): MyMessage {
  const message = { ...baseMyMessage } as MyMessage;
  message.mapOfStringvalues = {};
  if (object.mapOfStringvalues !== undefined && object.mapOfStringvalues !== null) {
    Object.entries(object.mapOfStringvalues).forEach(([key, value]) => {
      if (value !== undefined) {
        message.mapOfStringvalues[Number(key)] = string.fromPartial(value);
      }
    })
  }
  return message;
}
@stephenh
Copy link
Owner

🎉 This issue has been resolved in version 1.83.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@stephenh
Copy link
Owner

Nice, thanks @aikoven !

zfy0701 added a commit to sentioxyz/ts-proto that referenced this issue Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants