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

[renderers-js] Improve data enum helper when using a tuple variant with a single item #75

Open
lorisleiva opened this issue Jun 19, 2024 · 0 comments

Comments

@lorisleiva
Copy link
Member

When a EnumTupleVariantTypeNode contains a single item in the enum, we should transform the data enum helper such that it requires that item's value directly instead of having to wrap it in an array.

For instance, consider the following enum:

definedTypeNode({
  name: 'message',
  type: enumTypeNode([
    enumTupleVariantTypeNode(
      'write',
      tupleTypeNode([numberTypeNode('u16')])
    )
  ]),
})

Then instead of generating the following helper:

const myMessage = message('write', [42]);

We could simplify it to:

const myMessage = message('write', 42);
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

1 participant