Skip to content

compiler: destructured tuple/object param in .map() callback leaves JSX untransformed in output #2817

@matheuspoleza

Description

@matheuspoleza

When a .map() callback uses destructuring in its parameter list, the JSX inside the callback is emitted verbatim to the served source, causing a syntax error in the browser.

Repro

const entries: [string, string][] = [['a', 'Alpha'], ['b', 'Beta']];

function Tabs() {
  return (
    <div>
      {entries.map(([key, label]) => (
        <button key={key}>{label}</button>
      ))}
    </div>
  );
}

Actual

Browser console:

Uncaught SyntaxError: Unexpected token '<'

In the served .tsx (compiled output), the body is still raw JSX:

__append(__el13, __child(() => entries.map(([key, label]) => (
  <button key={key}>{label}</button>
))));

The outer structure is transformed, but <button> inside the callback isn't.

Expected

JSX inside .map() callbacks is transformed regardless of whether the callback parameter uses destructuring.

Workaround

Replace tuples/destructuring with object-shaped array entries:

const entries = [{ key: 'a', label: 'Alpha' }, { key: 'b', label: 'Beta' }];
entries.map((x) => <button key={x.key}>{x.label}</button>)

Environment

  • Vertz 0.2.64 (dev server)
  • macOS arm64, Node v22

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions