isConstructorType checks base constraint for undefined

Previously, it assumed there was always a base constraint, which is true
for correct code. For incorrect code, the base constraint may be
missing, which caused a crash because the base constraint was undefined.
This commit is contained in:
Nathan Shively-Sanders
2017-02-22 14:16:20 -08:00
parent 31c4ad193f
commit dbaf1f6756
4 changed files with 72 additions and 1 deletions

View File

@@ -3952,7 +3952,7 @@ namespace ts {
}
if (type.flags & TypeFlags.TypeVariable) {
const constraint = getBaseConstraintOfType(<TypeVariable>type);
return isValidBaseType(constraint) && isMixinConstructorType(constraint);
return constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint);
}
return false;
}