@@ -12146,7 +12146,8 @@ namespace ts {
1214612146 * Get JSX attributes type by trying to resolve openingLikeElement as a stateless function component.
1214712147 * Return all attributes type of resolved call signature including candidate signatures.
1214812148 * This function assumes that the caller handled other possible element type of the JSX element.
12149- * This function is a behavior used by language service when looking up completion in JSX element.,
12149+ * This function is a behavior used by language service when looking up completion in JSX element.
12150+ *
1215012151 * @param openingLikeElement a JSX opening-like element to find attributes type
1215112152 * @param elementType a type of the opening-like element. This elementType can't be an union type
1215212153 * @param elemInstanceType an element instance type (the result of newing or invoking this tag)
@@ -12203,10 +12204,12 @@ namespace ts {
1220312204 * declare function Foo(attr: { p1: string}): JSX.Element;
1220412205 * <Foo p1={10} />; // This function will try resolve "Foo" and return an attributes type of "Foo" which is "{ p1: string }"
1220512206 *
12206- * The function is intended to initially be called from getAttributesTypeFromJsxOpeningLikeElement which already handle JSX-intrinsic-element.
12207+ * The function is intended to initially be called from getAttributesTypeFromJsxOpeningLikeElement which already handle JSX-intrinsic-element..
12208+ * This function will try to resolve custom JSX attributes type in following order: string literal, stateless function, and stateful component
12209+ *
1220712210 * @param openingLikeElement a non-intrinsic JSXOPeningLikeElement
1220812211 * @param shouldIncludeAllStatelessAttributesType a boolean indicating whether to include all attributes types from all stateless function signature
12209- * @param elementType an instance type of the given opening-like element
12212+ * @param elementType an instance type of the given opening-like element. If undefined, the function will check type openinglikeElement's tagname.
1221012213 * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global (imported from react.d.ts)
1221112214 * @return attributes type if able to resolve the type of node
1221212215 * anyType if there is no type ElementAttributesProperty or there is an error
@@ -12352,6 +12355,7 @@ namespace ts {
1235212355 /**
1235312356 * Get attributes type of the given custom opening-like JSX element.
1235412357 * The function is intended to be called from a function which has handle intrinsic JSX element already.
12358+ *
1235512359 * @param node a custom JSX opening-like element
1235612360 */
1235712361 function getCustomJsxElementAttributesType(node: JsxOpeningLikeElement, shouldIncludeAllStatelessAttributesType: boolean): Type {
@@ -12364,10 +12368,12 @@ namespace ts {
1236412368 }
1236512369
1236612370 /**
12367- * Get all possible attributes type,especially in the case of overload stateless function component, of the given JSX opening-like element.
12371+ * Get all possible attributes type, especially for an overload stateless function component, of the given JSX opening-like element.
1236812372 * This function is called by language service (see: completions-tryGetGlobalSymbols)
12373+ *
1236912374 * Because in language service, the given JSX opening-like element may be incomplete and therefore, we can't resolve to exact signature if the element
1237012375 * is a stateless function component so the best thing to do is return all attributes type from all overloads.
12376+ *
1237112377 * @param node a JSX opening-like element to get attributes type for
1237212378 */
1237312379 function getAllAttributesTypeFromJsxOpeningLikeElement(node: JsxOpeningLikeElement): Type {
@@ -12381,6 +12387,7 @@ namespace ts {
1238112387
1238212388 /**
1238312389 * Get the attributes type which is the type that indicate which attributes are valid on the given JSXOpeningLikeElement.
12390+ *
1238412391 * @param node a JSXOpeningLikeElement node
1238512392 * @return an attributes type of the given node
1238612393 */
@@ -14052,10 +14059,15 @@ namespace ts {
1405214059 }
1405314060
1405414061 /**
14055- *
14056- * @param openingLikeElement
14057- * @param elementType
14058- * @param candidatesOutArray
14062+ * This function is similar to getResolvedSignature but exclusively for trying to resolve JSX stateless-function component.
14063+ * The main reason we have to use this function because, the caller of this function will already check the type of openingLikeElement's tagname
14064+ * pass the type as elementType. The elementType can not be a union (as such case should be handled by the caller of this function)
14065+ * At this point, it is still not sure whether the opening-like element is a stateless function component or not.
14066+ *
14067+ * @param openingLikeElement an opening-like JSX element to try to resolve as JSX stateless function
14068+ * @param elementType an element type of the opneing-like element by checking opening-like element's tagname.
14069+ * @param candidatesOutArray an array of signature to be filled in by the function. It is passed by signature help in the language service;
14070+ * the function will fill it up with appropriate candidate signatures
1405914071 */
1406014072 function getResolvedJsxStatelessFunctionSignature(openingLikeElement: JsxOpeningLikeElement, elementType: Type, candidatesOutArray: Signature[]): Signature {
1406114073 Debug.assert(!(elementType.flags & TypeFlags.Union));
@@ -14080,7 +14092,7 @@ namespace ts {
1408014092 }
1408114093
1408214094 /**
14083- * Try treating a given opening-like element as stateless function component and try to resolve a signature.
14095+ * Try treating a given opening-like element as stateless function component and resolve a tag-name to a function signature.
1408414096 * @param openingLikeElement an JsxOpeningLikeElement we want to try resolve its state-less function if possible
1408514097 * @param elementType a type of the opening-like JSX element, a result of resolving tagName in opening-like element.
1408614098 * @param candidatesOutArray an array of signature to be filled in by the function. It is passed by signature help in the language service;
0 commit comments