-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Add spread syntax to JsxExpression #11591
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
Conversation
This allows you to specify that a JsxExpression should be a list that will be flattened by the JSX consumer.
And baselines
@yuit @RyanCavanaugh can one of you take a look at this? |
@@ -10904,7 +10904,11 @@ namespace ts { | |||
|
|||
function checkJsxExpression(node: JsxExpression) { | |||
if (node.expression) { | |||
return checkExpression(node.expression); | |||
const type = checkExpression(node.expression); | |||
if (node.dotDotDotToken && !isArrayType(type)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check for type being any
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Needs tests for |
tsxSpreadChildrenInvalidType.tsx tests |
@RyanCavanaugh I just noticed that I forgot about this. Is it good to go in? |
@sandersn can you please refresh this PR. |
return checkExpression(node.expression); | ||
const type = checkExpression(node.expression); | ||
if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) { | ||
error(node, Diagnostics.JSX_spread_child_must_be_an_array_type, node.toString(), typeToString(type)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These arguments are unused :(
Fixes #9495
This allows you to specify that a JsxExpression should be a list that will be flattened by the JSX consumer.
Thanks @yuit for your 30-minute crash course on how the compiler handles JSX!