@@ -13473,31 +13473,32 @@ namespace ts {
1347313473 node.parent.openingElement.attributes :
1347413474 undefined; // node.parent is JsxFragment with no attributes
1347513475
13476- if (jsxAttributes) {
13477- // When we trying to resolve JsxOpeningLikeElement as a stateless function element, we will already give its attributes a contextual type
13478- // which is a type of the parameter of the signature we are trying out.
13479- // If there is no contextual type (e.g. we are trying to resolve stateful component), get attributes type from resolving element's tagName
13480- const attributesType = getContextualType(jsxAttributes);
13476+ if (!jsxAttributes) {
13477+ return anyType; // don't check children of a fragment
13478+ }
1348113479
13482- if (!attributesType || isTypeAny(attributesType)) {
13483- return undefined;
13484- }
13480+ // When we trying to resolve JsxOpeningLikeElement as a stateless function element, we will already give its attributes a contextual type
13481+ // which is a type of the parameter of the signature we are trying out.
13482+ // If there is no contextual type (e.g. we are trying to resolve stateful component), get attributes type from resolving element's tagName
13483+ const attributesType = getContextualType(jsxAttributes);
1348513484
13486- if (isJsxAttribute(node.parent)) {
13487- // JSX expression is in JSX attribute
13488- return getTypeOfPropertyOfContextualType(attributesType, node.parent.name.escapedText);
13489- }
13490- else if (node.parent.kind === SyntaxKind.JsxElement) {
13491- // JSX expression is in children of JSX Element, we will look for an "children" atttribute (we get the name from JSX.ElementAttributesProperty)
13492- const jsxChildrenPropertyName = getJsxElementChildrenPropertyname();
13493- return jsxChildrenPropertyName && jsxChildrenPropertyName !== "" ? getTypeOfPropertyOfContextualType(attributesType, jsxChildrenPropertyName) : anyType;
13494- }
13495- else {
13496- // JSX expression is in JSX spread attribute
13497- return attributesType;
13498- }
13485+ if (!attributesType || isTypeAny(attributesType)) {
13486+ return undefined;
13487+ }
13488+
13489+ if (isJsxAttribute(node.parent)) {
13490+ // JSX expression is in JSX attribute
13491+ return getTypeOfPropertyOfContextualType(attributesType, node.parent.name.escapedText);
13492+ }
13493+ else if (node.parent.kind === SyntaxKind.JsxElement) {
13494+ // JSX expression is in children of JSX Element, we will look for an "children" atttribute (we get the name from JSX.ElementAttributesProperty)
13495+ const jsxChildrenPropertyName = getJsxElementChildrenPropertyname();
13496+ return jsxChildrenPropertyName && jsxChildrenPropertyName !== "" ? getTypeOfPropertyOfContextualType(attributesType, jsxChildrenPropertyName) : anyType;
13497+ }
13498+ else {
13499+ // JSX expression is in JSX spread attribute
13500+ return attributesType;
1349913501 }
13500- return anyType; // don't check children of a fragment
1350113502 }
1350213503
1350313504 function getContextualTypeForJsxAttribute(attribute: JsxAttribute | JsxSpreadAttribute) {
0 commit comments