Skip to content

Add option to preset-react / transform-react-jsx to output object spread syntax #9652

Description

@Jessidhia

Feature Request

Is your feature request related to a problem? Please describe.
Currently, transform-react-jsx either outputs uses of the extend helper or calls to Object.assign for handling spread props (any attribute with {...Expression}).

Describe the solution you'd like
An option to instead convert such instances to an inline object with spread elements.

This would still allow @babel/preset-env to further transform the inline object if the allowed targets don't support object spread.

Teachability, Documentation, Adoption, Migration Strategy
If it wasn't a semver-major change I'd be as bold as to say that it's safe to make it enabled by default -- I suspect almost no project runs @babel/preset-react without also using @babel/preset-env, and native object rest spread has been supported by it even without requiring the shippedProposals option. It has also been shipping on browsers and node (LTS, even) for over a year.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions