@@ -21213,14 +21213,14 @@ namespace ts {
21213
21213
function getContextualTypeForArgumentAtIndex(callTarget: CallLikeExpression, argIndex: number, contextFlags?: ContextFlags): Type {
21214
21214
// If we're already in the process of resolving the given signature, don't resolve again as
21215
21215
// that could cause infinite recursion. Instead, return anySignature.
21216
- const signature = getNodeLinks(callTarget).resolvedSignature === resolvingSignature ? resolvingSignature : getResolvedSignature(callTarget);
21216
+ let signature = getNodeLinks(callTarget).resolvedSignature === resolvingSignature ? resolvingSignature : getResolvedSignature(callTarget);
21217
+ if (contextFlags && contextFlags & ContextFlags.BaseConstraint && signature.target && !hasTypeArguments(callTarget)) {
21218
+ signature = getBaseSignature(signature.target);
21219
+ }
21220
+
21217
21221
if (isJsxOpeningLikeElement(callTarget) && argIndex === 0) {
21218
21222
return getEffectiveFirstArgumentForJsxSignature(signature, callTarget);
21219
21223
}
21220
- if (contextFlags && contextFlags & ContextFlags.BaseConstraint && signature.target && !hasTypeArguments(callTarget)) {
21221
- const baseSignature = getBaseSignature(signature.target);
21222
- return getTypeAtPosition(baseSignature, argIndex);
21223
- }
21224
21224
return getTypeAtPosition(signature, argIndex);
21225
21225
}
21226
21226
@@ -21645,7 +21645,7 @@ namespace ts {
21645
21645
return getContextualTypeForJsxAttribute(<JsxAttribute | JsxSpreadAttribute>parent);
21646
21646
case SyntaxKind.JsxOpeningElement:
21647
21647
case SyntaxKind.JsxSelfClosingElement:
21648
- return getContextualJsxElementAttributesType(<JsxOpeningLikeElement>parent);
21648
+ return getContextualJsxElementAttributesType(<JsxOpeningLikeElement>parent, contextFlags );
21649
21649
}
21650
21650
return undefined;
21651
21651
}
@@ -21655,18 +21655,20 @@ namespace ts {
21655
21655
return ancestor && ancestor.inferenceContext!;
21656
21656
}
21657
21657
21658
- function getContextualJsxElementAttributesType(node: JsxOpeningLikeElement) {
21659
- if (isJsxOpeningElement(node) && node.parent.contextualType) {
21658
+ function getContextualJsxElementAttributesType(node: JsxOpeningLikeElement, contextFlags?: ContextFlags ) {
21659
+ if (isJsxOpeningElement(node) && node.parent.contextualType && contextFlags !== ContextFlags.BaseConstraint ) {
21660
21660
// Contextually applied type is moved from attributes up to the outer jsx attributes so when walking up from the children they get hit
21661
21661
// _However_ to hit them from the _attributes_ we must look for them here; otherwise we'll used the declared type
21662
21662
// (as below) instead!
21663
21663
return node.parent.contextualType;
21664
21664
}
21665
- return getContextualTypeForArgumentAtIndex(node, 0);
21665
+ return getContextualTypeForArgumentAtIndex(node, 0, contextFlags );
21666
21666
}
21667
21667
21668
21668
function getEffectiveFirstArgumentForJsxSignature(signature: Signature, node: JsxOpeningLikeElement) {
21669
- return getJsxReferenceKind(node) !== JsxReferenceKind.Component ? getJsxPropsTypeFromCallSignature(signature, node) : getJsxPropsTypeFromClassType(signature, node);
21669
+ return getJsxReferenceKind(node) !== JsxReferenceKind.Component
21670
+ ? getJsxPropsTypeFromCallSignature(signature, node)
21671
+ : getJsxPropsTypeFromClassType(signature, node);
21670
21672
}
21671
21673
21672
21674
function getJsxPropsTypeFromCallSignature(sig: Signature, context: JsxOpeningLikeElement) {
0 commit comments