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);
|
checkDecorators(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkTypeArgumentConstraints(typeParameters: TypeParameter[], typeArguments: TypeNode[]) {
|
function checkTypeArgumentConstraints(typeParameters: TypeParameter[], typeArguments: TypeNode[]): boolean {
|
||||||
if (produceDiagnostics) {
|
let result = true;
|
||||||
for (let i = 0; i < typeParameters.length; i++) {
|
for (let i = 0; i < typeParameters.length; i++) {
|
||||||
let constraint = getConstraintOfTypeParameter(typeParameters[i]);
|
let constraint = getConstraintOfTypeParameter(typeParameters[i]);
|
||||||
if (constraint) {
|
if (constraint) {
|
||||||
let typeArgument = typeArguments[i];
|
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) {
|
function checkTypeReferenceNode(node: TypeReferenceNode | ExpressionWithTypeArguments) {
|
||||||
|
@ -8991,9 +8991,11 @@ namespace ts {
|
||||||
if (type !== unknownType && node.typeArguments) {
|
if (type !== unknownType && node.typeArguments) {
|
||||||
// Do type argument local checks only if referenced type is successfully resolved
|
// Do type argument local checks only if referenced type is successfully resolved
|
||||||
forEach(node.typeArguments, checkSourceElement);
|
forEach(node.typeArguments, checkSourceElement);
|
||||||
let symbol = getNodeLinks(node).resolvedSymbol;
|
if (produceDiagnostics) {
|
||||||
let typeParameters = symbol.flags & SymbolFlags.TypeAlias ? getSymbolLinks(symbol).typeParameters : (<TypeReference>type).target.localTypeParameters;
|
let symbol = getNodeLinks(node).resolvedSymbol;
|
||||||
checkTypeArgumentConstraints(typeParameters, node.typeArguments);
|
let typeParameters = symbol.flags & SymbolFlags.TypeAlias ? getSymbolLinks(symbol).typeParameters : (<TypeReference>type).target.localTypeParameters;
|
||||||
|
checkTypeArgumentConstraints(typeParameters, node.typeArguments);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10595,7 +10597,9 @@ namespace ts {
|
||||||
if (baseTypeNode.typeArguments) {
|
if (baseTypeNode.typeArguments) {
|
||||||
forEach(baseTypeNode.typeArguments, checkSourceElement);
|
forEach(baseTypeNode.typeArguments, checkSourceElement);
|
||||||
for (let constructor of getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments)) {
|
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);
|
checkTypeAssignableTo(type, baseType, node.name || node, Diagnostics.Class_0_incorrectly_extends_base_class_1);
|
||||||
|
|
Loading…
Reference in a new issue