mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-17 00:34:47 -05:00
getConstraintDeclaration gets the first declaration with a constraint, rather than just the first declaration
This commit is contained in:
@@ -8972,8 +8972,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getConstraintDeclaration(type: TypeParameter) {
|
||||
const decl = type.symbol && getDeclarationOfKind<TypeParameterDeclaration>(type.symbol, SyntaxKind.TypeParameter);
|
||||
return decl && getEffectiveConstraintOfTypeParameter(decl);
|
||||
return mapDefined(filter(type.symbol && type.symbol.declarations, isTypeParameterDeclaration), getEffectiveConstraintOfTypeParameter)[0];
|
||||
}
|
||||
|
||||
function getInferredTypeParameterConstraint(typeParameter: TypeParameter) {
|
||||
@@ -29233,11 +29232,10 @@ namespace ts {
|
||||
const constraint = getEffectiveConstraintOfTypeParameter(source);
|
||||
const sourceConstraint = constraint && getTypeFromTypeNode(constraint);
|
||||
const targetConstraint = getConstraintOfTypeParameter(target);
|
||||
if (sourceConstraint) {
|
||||
// relax check if later interface augmentation has no constraint
|
||||
if (!targetConstraint || !isTypeIdenticalTo(sourceConstraint, targetConstraint)) {
|
||||
return false;
|
||||
}
|
||||
// relax check if later interface augmentation has no constraint, it's more broad and is OK to merge with
|
||||
// a more constrained interface (this could be generalized to a full heirarchy check, but that's maybe overkill)
|
||||
if (sourceConstraint && targetConstraint && !isTypeIdenticalTo(sourceConstraint, targetConstraint)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the type parameter node has a default and it is not identical to the default
|
||||
|
||||
Reference in New Issue
Block a user