@@ -5950,7 +5950,8 @@ namespace ts {
5950
5950
5951
5951
/** A type parameter is thisless if its contraint is thisless, or if it has no constraint. */
5952
5952
function isThislessTypeParameter(node: TypeParameterDeclaration) {
5953
- return !node.constraint || isThislessType(node.constraint);
5953
+ const constraint = getEffectiveConstraintOfTypeParameter(node);
5954
+ return !constraint || isThislessType(constraint);
5954
5955
}
5955
5956
5956
5957
/**
@@ -6737,7 +6738,7 @@ namespace ts {
6737
6738
}
6738
6739
6739
6740
function getConstraintDeclarationForMappedType(type: MappedType) {
6740
- return type.declaration.typeParameter.constraint ;
6741
+ return getEffectiveConstraintOfTypeParameter( type.declaration.typeParameter) ;
6741
6742
}
6742
6743
6743
6744
function isMappedTypeWithKeyofConstraintDeclaration(type: MappedType) {
@@ -7874,7 +7875,7 @@ namespace ts {
7874
7875
7875
7876
function getConstraintDeclaration(type: TypeParameter) {
7876
7877
const decl = type.symbol && getDeclarationOfKind<TypeParameterDeclaration>(type.symbol, SyntaxKind.TypeParameter);
7877
- return decl && decl.constraint ;
7878
+ return decl && getEffectiveConstraintOfTypeParameter( decl) ;
7878
7879
}
7879
7880
7880
7881
function getInferredTypeParameterConstraint(typeParameter: TypeParameter) {
@@ -7938,7 +7939,9 @@ namespace ts {
7938
7939
}
7939
7940
7940
7941
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);
7942
7945
}
7943
7946
7944
7947
function getTypeListId(types: ReadonlyArray<Type> | undefined) {
@@ -22008,7 +22011,7 @@ namespace ts {
22008
22011
checkSourceElement(node.default);
22009
22012
const typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node));
22010
22013
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));
22012
22015
}
22013
22016
if (!hasNonCircularTypeParameterDefault(typeParameter)) {
22014
22017
error(node.default, Diagnostics.Type_parameter_0_has_a_circular_default, typeToString(typeParameter));
@@ -22741,7 +22744,7 @@ namespace ts {
22741
22744
22742
22745
const type = <MappedType>getTypeFromMappedTypeNode(node);
22743
22746
const constraintType = getConstraintTypeFromMappedType(type);
22744
- checkTypeAssignableTo(constraintType, keyofConstraintType, node.typeParameter.constraint );
22747
+ checkTypeAssignableTo(constraintType, keyofConstraintType, getEffectiveConstraintOfTypeParameter( node.typeParameter) );
22745
22748
}
22746
22749
22747
22750
function checkThisType(node: ThisTypeNode) {
@@ -23632,6 +23635,13 @@ namespace ts {
23632
23635
checkSourceElement(node.typeExpression);
23633
23636
}
23634
23637
23638
+ function checkJSDocTemplateTag(node: JSDocTemplateTag): void {
23639
+ checkSourceElement(node.constraint);
23640
+ for (const tp of node.typeParameters) {
23641
+ checkSourceElement(tp);
23642
+ }
23643
+ }
23644
+
23635
23645
function checkJSDocTypeTag(node: JSDocTypeTag) {
23636
23646
checkSourceElement(node.typeExpression);
23637
23647
}
@@ -25422,7 +25432,8 @@ namespace ts {
25422
25432
25423
25433
// If the type parameter node does not have an identical constraint as the resolved
25424
25434
// 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);
25426
25437
const targetConstraint = getConstraintOfTypeParameter(target);
25427
25438
if (sourceConstraint) {
25428
25439
// relax check if later interface augmentation has no constraint
@@ -26642,6 +26653,8 @@ namespace ts {
26642
26653
case SyntaxKind.JSDocTypedefTag:
26643
26654
case SyntaxKind.JSDocCallbackTag:
26644
26655
return checkJSDocTypeAliasTag(node as JSDocTypedefTag);
26656
+ case SyntaxKind.JSDocTemplateTag:
26657
+ return checkJSDocTemplateTag(node as JSDocTemplateTag);
26645
26658
case SyntaxKind.JSDocTypeTag:
26646
26659
return checkJSDocTypeTag(node as JSDocTypeTag);
26647
26660
case SyntaxKind.JSDocParameterTag:
0 commit comments