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, MyEnum> generates incorrect output when stringEnums=true #543

Closed
raymondpebble opened this issue Mar 27, 2022 · 2 comments
Closed

Comments

@raymondpebble
Copy link

The generated code looks like this:

  fromJSON(object: any): MyMessage {
    const message = {...base} as MyMessage;
    message.mapOfEnums = Object.entries(object.mapOfEnums ?? {}).reduce<{[key: string]: MyEnum}>(
      (acc, [key, value]) => {
        acc[key] = value as number;
        return acc;
      },
      {},
    )

Assigning value as number to acc[key] is an error when using string enums.

@raymondpebble raymondpebble changed the title map<string, MyEnum> fails with stringEnums=true map<string, MyEnum> generates incorrect output when stringEnums=true Mar 27, 2022
@stephenh
Copy link
Owner

stephenh commented Apr 8, 2022

@raymondpebble thanks for filing; I think that this was just fixed by #529 ? I'm pretty sure enough that I'm going to close this as a duplicate, but let me know if not. Thanks!

@stephenh stephenh closed this as completed Apr 8, 2022
@raymondpebble
Copy link
Author

Oh awesome, thank you! Sorry I didn't see that :)

This issue was closed.
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