@@ -13211,6 +13211,8 @@ namespace ts {
13211
13211
let attributesTable = createMap<Symbol>();
13212
13212
let spread: Type = emptyObjectType;
13213
13213
let attributesArray: Symbol[] = [];
13214
+ let hasSpreadAnyType = false;
13215
+
13214
13216
for (const attributeDecl of attributes.properties) {
13215
13217
const member = attributeDecl.symbol;
13216
13218
if (isJsxAttribute(attributeDecl)) {
@@ -13239,31 +13241,33 @@ namespace ts {
13239
13241
const exprType = checkExpression(attributeDecl.expression);
13240
13242
if (!isValidSpreadType(exprType)) {
13241
13243
error(attributeDecl, Diagnostics.Spread_types_may_only_be_created_from_object_types);
13242
- return anyType ;
13244
+ hasSpreadAnyType = true ;
13243
13245
}
13244
13246
if (isTypeAny(exprType)) {
13245
- return anyType ;
13247
+ hasSpreadAnyType = true ;
13246
13248
}
13247
13249
spread = getSpreadType(spread, exprType);
13248
13250
}
13249
13251
}
13250
13252
13251
- if (spread !== emptyObjectType) {
13252
- if (attributesArray.length > 0) {
13253
- spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable));
13254
- attributesArray = [];
13255
- attributesTable = createMap<Symbol>();
13253
+ if (!hasSpreadAnyType) {
13254
+ if (spread !== emptyObjectType) {
13255
+ if (attributesArray.length > 0) {
13256
+ spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable));
13257
+ attributesArray = [];
13258
+ attributesTable = createMap<Symbol>();
13259
+ }
13260
+ attributesArray = getPropertiesOfType(spread);
13256
13261
}
13257
- attributesArray = getPropertiesOfType(spread);
13258
- }
13259
13262
13260
- attributesTable = createMap<Symbol>();
13261
- if (attributesArray) {
13262
- forEach(attributesArray, (attr) => {
13263
- if (!filter || filter(attr)) {
13264
- attributesTable.set(attr.name, attr);
13265
- }
13266
- });
13263
+ attributesTable = createMap<Symbol>();
13264
+ if (attributesArray) {
13265
+ forEach(attributesArray, (attr) => {
13266
+ if (!filter || filter(attr)) {
13267
+ attributesTable.set(attr.name, attr);
13268
+ }
13269
+ });
13270
+ }
13267
13271
}
13268
13272
13269
13273
// Handle children attribute
@@ -13287,7 +13291,7 @@ namespace ts {
13287
13291
// Error if there is a attribute named "children" and children element.
13288
13292
// This is because children element will overwrite the value from attributes
13289
13293
const jsxChildrenPropertyName = getJsxElementChildrenPropertyname();
13290
- if (jsxChildrenPropertyName && jsxChildrenPropertyName !== "") {
13294
+ if (!hasSpreadAnyType && jsxChildrenPropertyName && jsxChildrenPropertyName !== "") {
13291
13295
if (attributesTable.has(jsxChildrenPropertyName)) {
13292
13296
error(attributes, Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, jsxChildrenPropertyName);
13293
13297
}
@@ -13301,7 +13305,7 @@ namespace ts {
13301
13305
}
13302
13306
}
13303
13307
13304
- return createJsxAttributesType(attributes.symbol, attributesTable);
13308
+ return hasSpreadAnyType ? anyType : createJsxAttributesType(attributes.symbol, attributesTable);
13305
13309
13306
13310
/**
13307
13311
* Create anonymous type from given attributes symbol table.
0 commit comments