mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-18 13:59:04 -05:00
Cherry-pick PR #33426 into release-3.6
Component commits:4ae62c3884getConstraintDeclaration gets the first declaration with a constraint, rather than just the first declarationb1ad54b382Add type annotation2232f5ebaaUpdate comment
This commit is contained in:
committed by
typescript-bot
parent
46ccaa29d6
commit
391a73b598
@@ -8940,9 +8940,8 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getConstraintDeclaration(type: TypeParameter) {
|
||||
const decl = type.symbol && getDeclarationOfKind<TypeParameterDeclaration>(type.symbol, SyntaxKind.TypeParameter);
|
||||
return decl && getEffectiveConstraintOfTypeParameter(decl);
|
||||
function getConstraintDeclaration(type: TypeParameter): TypeNode | undefined {
|
||||
return mapDefined(filter(type.symbol && type.symbol.declarations, isTypeParameterDeclaration), getEffectiveConstraintOfTypeParameter)[0];
|
||||
}
|
||||
|
||||
function getInferredTypeParameterConstraint(typeParameter: TypeParameter) {
|
||||
@@ -29185,11 +29184,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