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

adjust js generated enum style #1

Closed
teamplayer3 opened this issue Oct 5, 2022 · 0 comments
Closed

adjust js generated enum style #1

teamplayer3 opened this issue Oct 5, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@teamplayer3
Copy link
Owner

Use the first enum style like in this wasm proposal.

type MyEnum =
  | { tag: 'A' }
  | { tag: 'B', value: number }
  | { tag: 'C', value: [number, number] }
  | { tag: 'D', value: { x: number, y: number }
  ;

It allows writing switch cases:

switch (enum.tag) {
    case 'A': ...; break;
    case 'B': .... 
}
@teamplayer3 teamplayer3 added the enhancement New feature or request label Oct 5, 2022
teamplayer3 added a commit that referenced this issue Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant