Skip to content

Improve data enum helper when using a tuple variant with a single item #7

@lorisleiva

Description

@lorisleiva

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions