@@ -8650,7 +8650,7 @@ namespace ts {
8650
8650
// is considered known if the object type is empty and the check is for assignability, if the object type has
8651
8651
// index signatures, or if the property is actually declared in the object type. In a union or intersection
8652
8652
// type, a property is considered known if it is known in any constituent type.
8653
- function isKnownProperty(type: Type, name: string, isComparingJsxAttributes: boolean, containsSynthesizedJsxChildren: boolean ): boolean {
8653
+ function isKnownProperty(type: Type, name: string, isComparingJsxAttributes: boolean): boolean {
8654
8654
if (type.flags & TypeFlags.Object) {
8655
8655
const resolved = resolveStructuredTypeMembers(<ObjectType>type);
8656
8656
if ((relation === assignableRelation || relation === comparableRelation) &&
@@ -8660,16 +8660,14 @@ namespace ts {
8660
8660
else if (resolved.stringIndexInfo || (resolved.numberIndexInfo && isNumericLiteralName(name))) {
8661
8661
return true;
8662
8662
}
8663
- else if (getPropertyOfType(type, name) || containsSynthesizedJsxChildren || (isComparingJsxAttributes && !isUnhyphenatedJsxName(name))) {
8664
- // For JSXAttributes, consider that the attribute to be known if
8665
- // 1. the attribute has a hyphenated name
8666
- // 2. "children" attribute that is synthesized from children property of Jsx element
8663
+ else if (getPropertyOfType(type, name) || (isComparingJsxAttributes && !isUnhyphenatedJsxName(name))) {
8664
+ // For JSXAttributes, consider that the attribute to be known if the attribute has a hyphenated name
8667
8665
return true;
8668
8666
}
8669
8667
}
8670
8668
else if (type.flags & TypeFlags.UnionOrIntersection) {
8671
8669
for (const t of (<UnionOrIntersectionType>type).types) {
8672
- if (isKnownProperty(t, name, isComparingJsxAttributes, containsSynthesizedJsxChildren )) {
8670
+ if (isKnownProperty(t, name, isComparingJsxAttributes)) {
8673
8671
return true;
8674
8672
}
8675
8673
}
@@ -8680,15 +8678,14 @@ namespace ts {
8680
8678
function hasExcessProperties(source: FreshObjectLiteralType, target: Type, reportErrors: boolean): boolean {
8681
8679
if (maybeTypeOfKind(target, TypeFlags.Object) && !(getObjectFlags(target) & ObjectFlags.ObjectLiteralPatternWithComputedProperties)) {
8682
8680
const isComparingJsxAttributes = !!(source.flags & TypeFlags.JsxAttributes);
8683
- const containsSynthesizedJsxChildren = !!(source.flags & TypeFlags.ContainsSynthesizedJsxChildren);
8684
8681
for (const prop of getPropertiesOfObjectType(source)) {
8685
- if (!isKnownProperty(target, prop.name, isComparingJsxAttributes, containsSynthesizedJsxChildren )) {
8682
+ if (!isKnownProperty(target, prop.name, isComparingJsxAttributes)) {
8686
8683
if (reportErrors) {
8687
8684
// We know *exactly* where things went wrong when comparing the types.
8688
8685
// Use this property as the error node as this will be more helpful in
8689
8686
// reasoning about what went wrong.
8690
8687
Debug.assert(!!errorNode);
8691
- if (isJsxAttributes(errorNode)) {
8688
+ if (isJsxAttributes(errorNode) || isJsxOpeningLikeElement(errorNode) ) {
8692
8689
// JsxAttributes has an object-literal flag and undergo same type-assignablity check as normal object-literal.
8693
8690
// However, using an object-literal error message will be very confusing to the users so we give different a message.
8694
8691
reportError(Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(target));
@@ -13303,7 +13300,6 @@ namespace ts {
13303
13300
// Handle children attribute
13304
13301
const parent = openingLikeElement.parent.kind === SyntaxKind.JsxElement ?
13305
13302
openingLikeElement.parent as JsxElement : undefined;
13306
- let containsSynthesizedJsxChildren = false;
13307
13303
// We have to check that openingElement of the parent is the one we are visiting as this may not be true for selfClosingElement
13308
13304
if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) {
13309
13305
// Error if there is a attribute named "children" and children element.
@@ -13344,8 +13340,7 @@ namespace ts {
13344
13340
function createJsxAttributesType(symbol: Symbol, attributesTable: Map<Symbol>) {
13345
13341
const result = createAnonymousType(symbol, attributesTable, emptyArray, emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined);
13346
13342
const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : TypeFlags.FreshLiteral;
13347
- const containsSynthesizedJsxChildrenFlag = containsSynthesizedJsxChildren ? TypeFlags.ContainsSynthesizedJsxChildren : 0;
13348
- result.flags |= TypeFlags.JsxAttributes | TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | containsSynthesizedJsxChildrenFlag;
13343
+ result.flags |= TypeFlags.JsxAttributes | TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag;
13349
13344
result.objectFlags |= ObjectFlags.ObjectLiteral;
13350
13345
return result;
13351
13346
}
0 commit comments