Skip to content

JSX is still not transformed to React.createElement when inside spread with target >=ES2018Β #55858

Closed

Description

πŸ”Ž Search Terms

JSX, spread, React.createElement

πŸ•— Version & Regression Information

Issue is first seen in 5.1.6, and forward to 5.2.2 and the current nightly version.

⏯ Playground Link

https://www.typescriptlang.org/play?target=5&ts=5.2.2#code/DwYQ9gtgDgBATgSwOYAsAuBeA3sAJggNwD4APYAen2IF8YsA6RrGAdzjADskAuGPQ0hSpFq1ckQCwAKCA

πŸ’» Code

<Comp right={<div>x</div>} {...{ wrong: <div>x</div>}}/>

πŸ™ Actual behavior

React.createElement(Comp, { right: React.createElement("div", null, "x"), wrong: <div>x</div> });

πŸ™‚ Expected behavior

React.createElement(Comp, { right: React.createElement("div", null, "x"), wrong: React.createElement("div", null, "x") });

Additional information about the issue

The same bug seems to have been fixed in #54425, but only when the target is ES2017 or below. When target is set to ES2018 or above the issue still exists.

Activity

  1. Andarist commented on Sep 25, 2023

    @Andarist
    Contributor

    This one is also related: #55008 . Both of the mentioned fixes touched transformJsxAttributesToExpression but the fix likely also needs to be introduced to transformJsxAttributesToProps. I'll put up a PR for this soon.

  2. locked as resolved and limited conversation to collaborators on Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions