Transform JSX spread children#45693
Conversation
|
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
weswigham
left a comment
There was a problem hiding this comment.
A new test that doesn't downlevel all the way to the __spreadArray helper (so targeting es6) would be nice, just to capture the difference simply. Other than that, this looks good.
|
@weswigham Thanks! Assuming that downleveling and JSX are independent, can we add That's what I've done in the added commit. Otherwise I'd copy // @jsx: react
// @target: es6Not sure if retaining both targets (default and es6) adds anything though? |
Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>
#11591 added support for parsing and emitting JSX spread children, however
transformers/jsx.tsignoresJsxExpression#dotDotDotToken, so roughly it transforms<div>{...todos}</div>->React.createElement("div", null, todos)vs.React.createElement("div", null, ...todos).This isn't a problem for
React.createElement()because that runtime treats both cases equivalently (it flattens children), however it is an issue for pickier runtimes.This PR adds
factory.createSpreadElement()totransformers/jsx.tsifJsxExpression#dotDotDotTokenis defined.