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

Function getJsxPropsTypeFromClassType

test/fixtures/snapshot/typescript.js:73140–73180  ·  view source on GitHub ↗
(sig, context)

Source from the content-addressed store, hash-verified

73138 return attributesType;
73139 }
73140 function getJsxPropsTypeFromClassType(sig, context) {
73141 var ns = getJsxNamespaceAt(context);
73142 var forcedLookupLocation = getJsxElementPropertiesName(ns);
73143 var attributesType = forcedLookupLocation === undefined
73144 // If there is no type ElementAttributesProperty, return the type of the first parameter of the signature, which should be the props type
73145 ? getTypeOfFirstParameterOfSignatureWithFallback(sig, unknownType)
73146 : forcedLookupLocation === ""
73147 // If there is no e.g. 'props' member in ElementAttributesProperty, use the element class type instead
73148 ? getReturnTypeOfSignature(sig)
73149 // Otherwise get the type of the property on the signature return type
73150 : getJsxPropsTypeForSignatureFromMember(sig, forcedLookupLocation);
73151 if (!attributesType) {
73152 // There is no property named 'props' on this instance type
73153 if (!!forcedLookupLocation && !!ts.length(context.attributes.properties)) {
73154 error(context, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, ts.unescapeLeadingUnderscores(forcedLookupLocation));
73155 }
73156 return unknownType;
73157 }
73158 attributesType = getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType);
73159 if (isTypeAny(attributesType)) {
73160 // Props is of type 'any' or unknown
73161 return attributesType;
73162 }
73163 else {
73164 // Normal case -- add in IntrinsicClassElements<T> and IntrinsicElements
73165 var apparentAttributesType = attributesType;
73166 var intrinsicClassAttribs = getJsxType(JsxNames.IntrinsicClassAttributes, context);
73167 if (!isErrorType(intrinsicClassAttribs)) {
73168 var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol);
73169 var hostClassType = getReturnTypeOfSignature(sig);
73170 apparentAttributesType = intersectTypes(typeParams
73171 ? createTypeReference(intrinsicClassAttribs, fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), ts.isInJSFile(context)))
73172 : intrinsicClassAttribs, apparentAttributesType);
73173 }
73174 var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
73175 if (!isErrorType(intrinsicAttribs)) {
73176 apparentAttributesType = intersectTypes(intrinsicAttribs, apparentAttributesType);
73177 }
73178 return apparentAttributesType;
73179 }
73180 }
73181 function getIntersectedSignatures(signatures) {
73182 return ts.getStrictOptionValue(compilerOptions, "noImplicitAny")
73183 ? ts.reduceLeft(signatures, function (left, right) {

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…