@@ -206,7 +206,7 @@ namespace ts {
206
206
207
207
function convertJsxChildrenToChildrenPropAssignment ( children : readonly JsxChild [ ] ) {
208
208
const nonWhitespaceChildren = getSemanticJsxChildren ( children ) ;
209
- if ( length ( nonWhitespaceChildren ) === 1 ) {
209
+ if ( length ( nonWhitespaceChildren ) === 1 && ! ( nonWhitespaceChildren [ 0 ] as JsxExpression ) . dotDotDotToken ) {
210
210
const result = transformJsxChildToExpression ( nonWhitespaceChildren [ 0 ] ) ;
211
211
return result && factory . createPropertyAssignment ( "children" , result ) ;
212
212
}
@@ -221,7 +221,15 @@ namespace ts {
221
221
const attrs = keyAttr ? filter ( node . attributes . properties , p => p !== keyAttr ) : node . attributes . properties ;
222
222
const objectProperties = length ( attrs ) ? transformJsxAttributesToObjectProps ( attrs , childrenProp ) :
223
223
factory . createObjectLiteralExpression ( childrenProp ? [ childrenProp ] : emptyArray ) ; // When there are no attributes, React wants {}
224
- return visitJsxOpeningLikeElementOrFragmentJSX ( tagName , objectProperties , keyAttr , length ( getSemanticJsxChildren ( children || emptyArray ) ) , isChild , location ) ;
224
+ const nonWhitespaceChildren = getSemanticJsxChildren ( children || emptyArray ) ;
225
+ return visitJsxOpeningLikeElementOrFragmentJSX (
226
+ tagName ,
227
+ objectProperties ,
228
+ keyAttr ,
229
+ ( nonWhitespaceChildren [ 0 ] as JsxExpression ) ?. dotDotDotToken ? 2 : length ( nonWhitespaceChildren ) ,
230
+ isChild ,
231
+ location
232
+ ) ;
225
233
}
226
234
227
235
function visitJsxOpeningLikeElementOrFragmentJSX ( tagName : Expression , objectProperties : Expression , keyAttr : JsxAttribute | undefined , childrenLength : number , isChild : boolean , location : TextRange ) {
@@ -290,11 +298,12 @@ namespace ts {
290
298
childrenProps = result ;
291
299
}
292
300
}
301
+ const nonWhitespaceChildren = getSemanticJsxChildren ( children ) ;
293
302
return visitJsxOpeningLikeElementOrFragmentJSX (
294
303
getImplicitJsxFragmentReference ( ) ,
295
304
childrenProps || factory . createObjectLiteralExpression ( [ ] ) ,
296
305
/*keyAttr*/ undefined ,
297
- length ( getSemanticJsxChildren ( children ) ) ,
306
+ ( nonWhitespaceChildren [ 0 ] as JsxExpression ) ?. dotDotDotToken ? 2 : length ( nonWhitespaceChildren ) ,
298
307
isChild ,
299
308
location
300
309
) ;
0 commit comments