-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSX spread child can be a generator #51711
Comments
Related: #51328 |
This is explicitly not allowed by React, see facebook/react#13312 |
@RyanCavanaugh That patch is about rendering generators as components; this one is about spreading it as children. Each individual child is still a plain-function component or a tag. After spreading, it would not be observable to React. |
@RyanCavanaugh, I understand. |
This is a child spread, which is a JSX-specific feature, so we can't say for certain that it transforms to a runtime spread (as far as I know, React has not provided a spec for what any given JSX feature is truly a sugar for). Other transpilers, even as lately as this year, have not necessarily produced an ES iterator spread in their output when consuming this (favoring instead to present the argument as-is): evanw/esbuild#2245, so it's not a settled question. The unquestionably safe thing to write is this:
Sure, but it's what 98%+ of TS users are using. We can't possibly support any JSX framework anyone might come up with |
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Bug Report
🔎 Search Terms
JSX spread child must be an array type.
JSX spread child generator
JSX spread generator
ts(2609)
2609 generator
🕗 Version & Regression Information
⏯ Playground Link
Playground code
💻 Code
🙁 Actual behavior
An error is generated if a JSX.Element generator is used.
🙂 Expected behavior
The result of the compilation conforms to javascript and the code works. so the compiler doesn't need to fail in this case.
The text was updated successfully, but these errors were encountered: