(node, source, target, relation, containingMessageChain, errorOutputContainer)
| 64147 | } |
| 64148 | } |
| 64149 | function elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer) { |
| 64150 | var result = elaborateElementwise(generateJsxAttributes(node), source, target, relation, containingMessageChain, errorOutputContainer); |
| 64151 | var invalidTextDiagnostic; |
| 64152 | if (ts.isJsxOpeningElement(node.parent) && ts.isJsxElement(node.parent.parent)) { |
| 64153 | var containingElement = node.parent.parent; |
| 64154 | var childPropName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node)); |
| 64155 | var childrenPropName = childPropName === undefined ? "children" : ts.unescapeLeadingUnderscores(childPropName); |
| 64156 | var childrenNameType = getStringLiteralType(childrenPropName); |
| 64157 | var childrenTargetType = getIndexedAccessType(target, childrenNameType); |
| 64158 | var validChildren = ts.getSemanticJsxChildren(containingElement.children); |
| 64159 | if (!ts.length(validChildren)) { |
| 64160 | return result; |
| 64161 | } |
| 64162 | var moreThanOneRealChildren = ts.length(validChildren) > 1; |
| 64163 | var arrayLikeTargetParts = filterType(childrenTargetType, isArrayOrTupleLikeType); |
| 64164 | var nonArrayLikeTargetParts = filterType(childrenTargetType, function (t) { return !isArrayOrTupleLikeType(t); }); |
| 64165 | if (moreThanOneRealChildren) { |
| 64166 | if (arrayLikeTargetParts !== neverType) { |
| 64167 | var realSource = createTupleType(checkJsxChildren(containingElement, 0 /* CheckMode.Normal */)); |
| 64168 | var children = generateJsxChildren(containingElement, getInvalidTextualChildDiagnostic); |
| 64169 | result = elaborateElementwise(children, realSource, arrayLikeTargetParts, relation, containingMessageChain, errorOutputContainer) || result; |
| 64170 | } |
| 64171 | else if (!isTypeRelatedTo(getIndexedAccessType(source, childrenNameType), childrenTargetType, relation)) { |
| 64172 | // arity mismatch |
| 64173 | result = true; |
| 64174 | var diag = error(containingElement.openingElement.tagName, ts.Diagnostics.This_JSX_tag_s_0_prop_expects_a_single_child_of_type_1_but_multiple_children_were_provided, childrenPropName, typeToString(childrenTargetType)); |
| 64175 | if (errorOutputContainer && errorOutputContainer.skipLogging) { |
| 64176 | (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag); |
| 64177 | } |
| 64178 | } |
| 64179 | } |
| 64180 | else { |
| 64181 | if (nonArrayLikeTargetParts !== neverType) { |
| 64182 | var child = validChildren[0]; |
| 64183 | var elem_1 = getElaborationElementForJsxChild(child, childrenNameType, getInvalidTextualChildDiagnostic); |
| 64184 | if (elem_1) { |
| 64185 | result = elaborateElementwise((function () { return __generator(this, function (_a) { |
| 64186 | switch (_a.label) { |
| 64187 | case 0: return [4 /*yield*/, elem_1]; |
| 64188 | case 1: |
| 64189 | _a.sent(); |
| 64190 | return [2 /*return*/]; |
| 64191 | } |
| 64192 | }); })(), source, target, relation, containingMessageChain, errorOutputContainer) || result; |
| 64193 | } |
| 64194 | } |
| 64195 | else if (!isTypeRelatedTo(getIndexedAccessType(source, childrenNameType), childrenTargetType, relation)) { |
| 64196 | // arity mismatch |
| 64197 | result = true; |
| 64198 | var diag = error(containingElement.openingElement.tagName, ts.Diagnostics.This_JSX_tag_s_0_prop_expects_type_1_which_requires_multiple_children_but_only_a_single_child_was_provided, childrenPropName, typeToString(childrenTargetType)); |
| 64199 | if (errorOutputContainer && errorOutputContainer.skipLogging) { |
| 64200 | (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag); |
| 64201 | } |
| 64202 | } |
| 64203 | } |
| 64204 | } |
| 64205 | return result; |
| 64206 | function getInvalidTextualChildDiagnostic() { |
no test coverage detected
searching dependent graphs…