@@ -13248,6 +13248,8 @@ namespace ts {
13248
13248
let attributesTable = createMap<Symbol>();
13249
13249
let spread: Type = emptyObjectType;
13250
13250
let attributesArray: Symbol[] = [];
13251
+ let hasSpreadAnyType = false;
13252
+
13251
13253
for (const attributeDecl of attributes.properties) {
13252
13254
const member = attributeDecl.symbol;
13253
13255
if (isJsxAttribute(attributeDecl)) {
@@ -13276,31 +13278,33 @@ namespace ts {
13276
13278
const exprType = checkExpression(attributeDecl.expression);
13277
13279
if (!isValidSpreadType(exprType)) {
13278
13280
error(attributeDecl, Diagnostics.Spread_types_may_only_be_created_from_object_types);
13279
- return anyType ;
13281
+ hasSpreadAnyType = true ;
13280
13282
}
13281
13283
if (isTypeAny(exprType)) {
13282
- return anyType ;
13284
+ hasSpreadAnyType = true ;
13283
13285
}
13284
13286
spread = getSpreadType(spread, exprType);
13285
13287
}
13286
13288
}
13287
13289
13288
- if (spread !== emptyObjectType) {
13289
- if (attributesArray.length > 0) {
13290
- spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable));
13291
- attributesArray = [];
13292
- attributesTable = createMap<Symbol>();
13290
+ if (!hasSpreadAnyType) {
13291
+ if (spread !== emptyObjectType) {
13292
+ if (attributesArray.length > 0) {
13293
+ spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable));
13294
+ attributesArray = [];
13295
+ attributesTable = createMap<Symbol>();
13296
+ }
13297
+ attributesArray = getPropertiesOfType(spread);
13293
13298
}
13294
- attributesArray = getPropertiesOfType(spread);
13295
- }
13296
13299
13297
- attributesTable = createMap<Symbol>();
13298
- if (attributesArray) {
13299
- forEach(attributesArray, (attr) => {
13300
- if (!filter || filter(attr)) {
13301
- attributesTable.set(attr.name, attr);
13302
- }
13303
- });
13300
+ attributesTable = createMap<Symbol>();
13301
+ if (attributesArray) {
13302
+ forEach(attributesArray, (attr) => {
13303
+ if (!filter || filter(attr)) {
13304
+ attributesTable.set(attr.name, attr);
13305
+ }
13306
+ });
13307
+ }
13304
13308
}
13305
13309
13306
13310
// Handle children attribute
@@ -13324,7 +13328,7 @@ namespace ts {
13324
13328
// Error if there is a attribute named "children" and children element.
13325
13329
// This is because children element will overwrite the value from attributes
13326
13330
const jsxChildrenPropertyName = getJsxElementChildrenPropertyname();
13327
- if (jsxChildrenPropertyName && jsxChildrenPropertyName !== "") {
13331
+ if (!hasSpreadAnyType && jsxChildrenPropertyName && jsxChildrenPropertyName !== "") {
13328
13332
if (attributesTable.has(jsxChildrenPropertyName)) {
13329
13333
error(attributes, Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, jsxChildrenPropertyName);
13330
13334
}
@@ -13338,7 +13342,7 @@ namespace ts {
13338
13342
}
13339
13343
}
13340
13344
13341
- return createJsxAttributesType(attributes.symbol, attributesTable);
13345
+ return hasSpreadAnyType ? anyType : createJsxAttributesType(attributes.symbol, attributesTable);
13342
13346
13343
13347
/**
13344
13348
* Create anonymous type from given attributes symbol table.
0 commit comments