diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 579a234cb95..c164833ca47 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14107,11 +14107,8 @@ namespace ts { */ function resolveCustomJsxElementAttributesType(openingLikeElement: JsxOpeningLikeElement, shouldIncludeAllStatelessAttributesType: boolean, - elementType?: Type, + elementType: Type = checkExpression(openingLikeElement.tagName), elementClassType?: Type): Type { - if (!elementType) { - elementType = checkExpression(openingLikeElement.tagName); - } if (elementType.flags & TypeFlags.Union) { const types = (elementType as UnionType).types; @@ -14245,11 +14242,12 @@ namespace ts { */ function getCustomJsxElementAttributesType(node: JsxOpeningLikeElement, shouldIncludeAllStatelessAttributesType: boolean): Type { const links = getNodeLinks(node); - if (!links.resolvedJsxElementAttributesType) { + const linkLocation = shouldIncludeAllStatelessAttributesType ? "resolvedJsxElementAllAttributesType" : "resolvedJsxElementAttributesType"; + if (!links[linkLocation]) { const elemClassType = getJsxGlobalElementClassType(); - return links.resolvedJsxElementAttributesType = resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, /*elementType*/ undefined, elemClassType); + return links[linkLocation] = resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, /*elementType*/ undefined, elemClassType); } - return links.resolvedJsxElementAttributesType; + return links[linkLocation]; } /** diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 3b57608abc5..0eb7f03e3ec 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3067,6 +3067,7 @@ namespace ts { hasReportedStatementInAmbientContext?: boolean; // Cache boolean if we report statements in ambient context jsxFlags?: JsxFlags; // flags for knowing what kind of element/attributes we're dealing with resolvedJsxElementAttributesType?: Type; // resolved element attributes type of a JSX openinglike element + resolvedJsxElementAllAttributesType?: Type; // resolved all element attributes type of a JSX openinglike element hasSuperCall?: boolean; // recorded result when we try to find super-call. We only try to find one if this flag is undefined, indicating that we haven't made an attempt. superCall?: ExpressionStatement; // Cached first super-call found in the constructor. Used in checking whether super is called before this-accessing switchTypes?: Type[]; // Cached array of switch case expression types