@@ -5950,7 +5950,8 @@ namespace ts {
59505950
59515951 /** A type parameter is thisless if its contraint is thisless, or if it has no constraint. */
59525952 function isThislessTypeParameter(node: TypeParameterDeclaration) {
5953- return !node.constraint || isThislessType(node.constraint);
5953+ const constraint = getEffectiveConstraintOfTypeParameter(node);
5954+ return !constraint || isThislessType(constraint);
59545955 }
59555956
59565957 /**
@@ -6737,7 +6738,7 @@ namespace ts {
67376738 }
67386739
67396740 function getConstraintDeclarationForMappedType(type: MappedType) {
6740- return type.declaration.typeParameter.constraint ;
6741+ return getEffectiveConstraintOfTypeParameter( type.declaration.typeParameter) ;
67416742 }
67426743
67436744 function isMappedTypeWithKeyofConstraintDeclaration(type: MappedType) {
@@ -7874,7 +7875,7 @@ namespace ts {
78747875
78757876 function getConstraintDeclaration(type: TypeParameter) {
78767877 const decl = type.symbol && getDeclarationOfKind<TypeParameterDeclaration>(type.symbol, SyntaxKind.TypeParameter);
7877- return decl && decl.constraint ;
7878+ return decl && getEffectiveConstraintOfTypeParameter( decl) ;
78787879 }
78797880
78807881 function getInferredTypeParameterConstraint(typeParameter: TypeParameter) {
@@ -7938,7 +7939,9 @@ namespace ts {
79387939 }
79397940
79407941 function getParentSymbolOfTypeParameter(typeParameter: TypeParameter): Symbol | undefined {
7941- return getSymbolOfNode(getDeclarationOfKind(typeParameter.symbol, SyntaxKind.TypeParameter)!.parent);
7942+ const tp = getDeclarationOfKind<TypeParameterDeclaration>(typeParameter.symbol, SyntaxKind.TypeParameter)!;
7943+ const host = isJSDocTemplateTag(tp.parent) ? getHostSignatureFromJSDoc(tp.parent) : tp.parent;
7944+ return host && getSymbolOfNode(host);
79427945 }
79437946
79447947 function getTypeListId(types: ReadonlyArray<Type> | undefined) {
@@ -22008,7 +22011,7 @@ namespace ts {
2200822011 checkSourceElement(node.default);
2200922012 const typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node));
2201022013 if (!hasNonCircularBaseConstraint(typeParameter)) {
22011- error(node.constraint , Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter));
22014+ error(getEffectiveConstraintOfTypeParameter( node) , Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter));
2201222015 }
2201322016 if (!hasNonCircularTypeParameterDefault(typeParameter)) {
2201422017 error(node.default, Diagnostics.Type_parameter_0_has_a_circular_default, typeToString(typeParameter));
@@ -22741,7 +22744,7 @@ namespace ts {
2274122744
2274222745 const type = <MappedType>getTypeFromMappedTypeNode(node);
2274322746 const constraintType = getConstraintTypeFromMappedType(type);
22744- checkTypeAssignableTo(constraintType, keyofConstraintType, node.typeParameter.constraint );
22747+ checkTypeAssignableTo(constraintType, keyofConstraintType, getEffectiveConstraintOfTypeParameter( node.typeParameter) );
2274522748 }
2274622749
2274722750 function checkThisType(node: ThisTypeNode) {
@@ -23632,6 +23635,13 @@ namespace ts {
2363223635 checkSourceElement(node.typeExpression);
2363323636 }
2363423637
23638+ function checkJSDocTemplateTag(node: JSDocTemplateTag): void {
23639+ checkSourceElement(node.constraint);
23640+ for (const tp of node.typeParameters) {
23641+ checkSourceElement(tp);
23642+ }
23643+ }
23644+
2363523645 function checkJSDocTypeTag(node: JSDocTypeTag) {
2363623646 checkSourceElement(node.typeExpression);
2363723647 }
@@ -25422,7 +25432,8 @@ namespace ts {
2542225432
2542325433 // If the type parameter node does not have an identical constraint as the resolved
2542425434 // type parameter at this position, we report an error.
25425- const sourceConstraint = source.constraint && getTypeFromTypeNode(source.constraint);
25435+ const constraint = getEffectiveConstraintOfTypeParameter(source);
25436+ const sourceConstraint = constraint && getTypeFromTypeNode(constraint);
2542625437 const targetConstraint = getConstraintOfTypeParameter(target);
2542725438 if (sourceConstraint) {
2542825439 // relax check if later interface augmentation has no constraint
@@ -26642,6 +26653,8 @@ namespace ts {
2664226653 case SyntaxKind.JSDocTypedefTag:
2664326654 case SyntaxKind.JSDocCallbackTag:
2664426655 return checkJSDocTypeAliasTag(node as JSDocTypedefTag);
26656+ case SyntaxKind.JSDocTemplateTag:
26657+ return checkJSDocTemplateTag(node as JSDocTemplateTag);
2664526658 case SyntaxKind.JSDocTypeTag:
2664626659 return checkJSDocTypeTag(node as JSDocTypeTag);
2664726660 case SyntaxKind.JSDocParameterTag:
0 commit comments