MCPcopy Index your code
hub / github.com/nodejs/node / getContextualTypeForChildJsxExpression

Function getContextualTypeForChildJsxExpression

test/fixtures/snapshot/typescript.js:72837–72855  ·  view source on GitHub ↗
(node, child)

Source from the content-addressed store, hash-verified

72835 return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional, contextFlags) : undefined;
72836 }
72837 function getContextualTypeForChildJsxExpression(node, child) {
72838 var attributesType = getApparentTypeOfContextualType(node.openingElement.tagName);
72839 // JSX expression is in children of JSX Element, we will look for an "children" attribute (we get the name from JSX.ElementAttributesProperty)
72840 var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node));
72841 if (!(attributesType && !isTypeAny(attributesType) && jsxChildrenPropertyName && jsxChildrenPropertyName !== "")) {
72842 return undefined;
72843 }
72844 var realChildren = ts.getSemanticJsxChildren(node.children);
72845 var childIndex = realChildren.indexOf(child);
72846 var childFieldType = getTypeOfPropertyOfContextualType(attributesType, jsxChildrenPropertyName);
72847 return childFieldType && (realChildren.length === 1 ? childFieldType : mapType(childFieldType, function (t) {
72848 if (isArrayLikeType(t)) {
72849 return getIndexedAccessType(t, getNumberLiteralType(childIndex));
72850 }
72851 else {
72852 return t;
72853 }
72854 }, /*noReductions*/ true));
72855 }
72856 function getContextualTypeForJsxExpression(node) {
72857 var exprParent = node.parent;
72858 return ts.isJsxAttributeLike(exprParent)

Callers 1

Calls 10

getJsxNamespaceAtFunction · 0.85
isTypeAnyFunction · 0.85
mapTypeFunction · 0.85
isArrayLikeTypeFunction · 0.85
getIndexedAccessTypeFunction · 0.85
getNumberLiteralTypeFunction · 0.85
indexOfMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…