This is a worker function. Use getConstraintOfTypeParameter which guards against circular constraints.
(typeParameter)
| 60133 | } |
| 60134 | /** This is a worker function. Use getConstraintOfTypeParameter which guards against circular constraints. */ |
| 60135 | function getConstraintFromTypeParameter(typeParameter) { |
| 60136 | if (!typeParameter.constraint) { |
| 60137 | if (typeParameter.target) { |
| 60138 | var targetConstraint = getConstraintOfTypeParameter(typeParameter.target); |
| 60139 | typeParameter.constraint = targetConstraint ? instantiateType(targetConstraint, typeParameter.mapper) : noConstraintType; |
| 60140 | } |
| 60141 | else { |
| 60142 | var constraintDeclaration = getConstraintDeclaration(typeParameter); |
| 60143 | if (!constraintDeclaration) { |
| 60144 | typeParameter.constraint = getInferredTypeParameterConstraint(typeParameter) || noConstraintType; |
| 60145 | } |
| 60146 | else { |
| 60147 | var type = getTypeFromTypeNode(constraintDeclaration); |
| 60148 | if (type.flags & 1 /* TypeFlags.Any */ && !isErrorType(type)) { // Allow errorType to propegate to keep downstream errors suppressed |
| 60149 | // use keyofConstraintType as the base constraint for mapped type key constraints (unknown isn;t assignable to that, but `any` was), |
| 60150 | // use unknown otherwise |
| 60151 | type = constraintDeclaration.parent.parent.kind === 195 /* SyntaxKind.MappedType */ ? keyofConstraintType : unknownType; |
| 60152 | } |
| 60153 | typeParameter.constraint = type; |
| 60154 | } |
| 60155 | } |
| 60156 | } |
| 60157 | return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; |
| 60158 | } |
| 60159 | function getParentSymbolOfTypeParameter(typeParameter) { |
| 60160 | var tp = ts.getDeclarationOfKind(typeParameter.symbol, 163 /* SyntaxKind.TypeParameter */); |
| 60161 | var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getEffectiveContainerForJSDocTemplateTag(tp.parent) : tp.parent; |
no test coverage detected