Instantiate constraint with default upon comparison (#31240)

This commit is contained in:
Wesley Wigham
2019-05-11 16:40:23 -07:00
committed by GitHub
parent ae3d1d45c1
commit b7fe99a88c
5 changed files with 203 additions and 1 deletions

View File

@@ -24441,7 +24441,7 @@ namespace ts {
const constraintType = getConstraintOfTypeParameter(typeParameter);
const defaultType = getDefaultFromTypeParameter(typeParameter);
if (constraintType && defaultType) {
checkTypeAssignableTo(defaultType, getTypeWithThisArgument(constraintType, defaultType), node.default, Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
checkTypeAssignableTo(defaultType, getTypeWithThisArgument(instantiateType(constraintType, makeUnaryTypeMapper(typeParameter, defaultType)), defaultType), node.default, Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
}
if (produceDiagnostics) {
checkTypeNameIsReserved(node.name, Diagnostics.Type_parameter_name_cannot_be_0);