Addressing more CR feedback
This commit is contained in:
parent
471f6e0536
commit
efcccaa4f8
1 changed files with 16 additions and 12 deletions
|
@ -8973,16 +8973,16 @@ namespace ts {
|
|||
checkDecorators(node);
|
||||
}
|
||||
|
||||
function checkTypeArgumentConstraints(typeParameters: TypeParameter[], typeArguments: TypeNode[]) {
|
||||
if (produceDiagnostics) {
|
||||
function checkTypeArgumentConstraints(typeParameters: TypeParameter[], typeArguments: TypeNode[]): boolean {
|
||||
let result = true;
|
||||
for (let i = 0; i < typeParameters.length; i++) {
|
||||
let constraint = getConstraintOfTypeParameter(typeParameters[i]);
|
||||
if (constraint) {
|
||||
let typeArgument = typeArguments[i];
|
||||
checkTypeAssignableTo(getTypeFromTypeNode(typeArgument), constraint, typeArgument, Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
|
||||
}
|
||||
result = result && checkTypeAssignableTo(getTypeFromTypeNode(typeArgument), constraint, typeArgument, Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function checkTypeReferenceNode(node: TypeReferenceNode | ExpressionWithTypeArguments) {
|
||||
|
@ -8991,11 +8991,13 @@ namespace ts {
|
|||
if (type !== unknownType && node.typeArguments) {
|
||||
// Do type argument local checks only if referenced type is successfully resolved
|
||||
forEach(node.typeArguments, checkSourceElement);
|
||||
if (produceDiagnostics) {
|
||||
let symbol = getNodeLinks(node).resolvedSymbol;
|
||||
let typeParameters = symbol.flags & SymbolFlags.TypeAlias ? getSymbolLinks(symbol).typeParameters : (<TypeReference>type).target.localTypeParameters;
|
||||
checkTypeArgumentConstraints(typeParameters, node.typeArguments);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkTypeQuery(node: TypeQueryNode) {
|
||||
getTypeFromTypeQueryNode(node);
|
||||
|
@ -10595,7 +10597,9 @@ namespace ts {
|
|||
if (baseTypeNode.typeArguments) {
|
||||
forEach(baseTypeNode.typeArguments, checkSourceElement);
|
||||
for (let constructor of getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments)) {
|
||||
checkTypeArgumentConstraints(constructor.typeParameters, baseTypeNode.typeArguments);
|
||||
if (!checkTypeArgumentConstraints(constructor.typeParameters, baseTypeNode.typeArguments)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
checkTypeAssignableTo(type, baseType, node.name || node, Diagnostics.Class_0_incorrectly_extends_base_class_1);
|
||||
|
|
Loading…
Reference in a new issue