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

google.protobuf.Struct is invalid when generated with useMapType=true #739

Closed
roboslone opened this issue Dec 20, 2022 · 1 comment
Closed

Comments

@roboslone
Copy link
Contributor

Generated code:

  wrap(object: { [key: string]: any } | undefined): Struct {
    const struct = createBaseStruct();
    if (object !== undefined) {
      Object.keys(object).forEach((key) => {
        struct.fields[key] = object[key]; // <----------------
      });
    }
    return struct;
  },

  unwrap(message: Struct): { [key: string]: any } {
    const object: { [key: string]: any } = {};
    Object.keys(message.fields).forEach((key) => {
      object[key] = message.fields[key]; // <----------------
    });
    return object;
  },
google/protobuf/struct.ts:163:9 - error TS7052: Element implicitly has an 'any' type because type 'Map<string, any>' has no index signature. Did you mean to call 'struct.fields.set'?

163         struct.fields[key] = object[key];
            ~~~~~~~~~~~~~~~~~~

google/protobuf/struct.ts:172:21 - error TS7052: Element implicitly has an 'any' type because type 'Map<string, any>' has no index signature. Did you mean to call 'message.fields.get'?

172       object[key] = message.fields[key];
                        ~~~~~~~~~~~~~~~~~~~
@stephenh
Copy link
Owner

Fixed by #740, thanks @roboslone !

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