mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Addressing CR feedback
This commit is contained in:
+13
-12
@@ -4158,23 +4158,23 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
function getConstraintOfTypeParameter(type: TypeParameter): Type {
|
||||
if (!type.constraint) {
|
||||
if (type.target) {
|
||||
const targetConstraint = getConstraintOfTypeParameter(type.target);
|
||||
type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType;
|
||||
function getConstraintOfTypeParameter(typeParameter: TypeParameter): Type {
|
||||
if (!typeParameter.constraint) {
|
||||
if (typeParameter.target) {
|
||||
const targetConstraint = getConstraintOfTypeParameter(typeParameter.target);
|
||||
typeParameter.constraint = targetConstraint ? instantiateType(targetConstraint, typeParameter.mapper) : noConstraintType;
|
||||
}
|
||||
else {
|
||||
const constraintDeclaration = getConstraintDeclaration(type);
|
||||
const constraintDeclaration = getConstraintDeclaration(typeParameter);
|
||||
let constraint = getTypeFromTypeNode(constraintDeclaration);
|
||||
if (hasConstraintReferenceTo(constraint, type)) {
|
||||
error(constraintDeclaration, Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(type));
|
||||
if (hasConstraintReferenceTo(constraint, typeParameter)) {
|
||||
error(constraintDeclaration, Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter));
|
||||
constraint = unknownType;
|
||||
}
|
||||
type.constraint = constraint;
|
||||
typeParameter.constraint = constraint;
|
||||
}
|
||||
}
|
||||
return type.constraint === noConstraintType ? undefined : type.constraint;
|
||||
return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint;
|
||||
}
|
||||
|
||||
function getParentSymbolOfTypeParameter(typeParameter: TypeParameter): Symbol {
|
||||
@@ -4721,8 +4721,9 @@ namespace ts {
|
||||
function getInferenceMapper(context: InferenceContext): TypeMapper {
|
||||
if (!context.mapper) {
|
||||
const mapper: TypeMapper = t => {
|
||||
for (let i = 0; i < context.typeParameters.length; i++) {
|
||||
if (t === context.typeParameters[i]) {
|
||||
const typeParameters = context.typeParameters;
|
||||
for (let i = 0; i < typeParameters.length; i++) {
|
||||
if (t === typeParameters[i]) {
|
||||
context.inferences[i].isFixed = true;
|
||||
return getInferredType(context, i);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user