Fix bug: Report errors on extends expression in JS even if an @augments tag is present (#18854)

This commit is contained in:
Andy
2017-10-02 10:33:53 -07:00
committed by GitHub
parent 141cd574c7
commit e6980722a6
5 changed files with 42 additions and 0 deletions

View File

@@ -4917,6 +4917,8 @@ namespace ts {
*/
function getBaseConstructorTypeOfClass(type: InterfaceType): Type {
if (!type.resolvedBaseConstructorType) {
const decl = <ClassLikeDeclaration>type.symbol.valueDeclaration;
const extended = getClassExtendsHeritageClauseElement(decl);
const baseTypeNode = getBaseTypeNodeOfClass(type);
if (!baseTypeNode) {
return type.resolvedBaseConstructorType = undefinedType;
@@ -4925,6 +4927,10 @@ namespace ts {
return unknownType;
}
const baseConstructorType = checkExpression(baseTypeNode.expression);
if (extended && baseTypeNode !== extended) {
Debug.assert(!extended.typeArguments); // Because this is in a JS file, and baseTypeNode is in an @extends tag
checkExpression(extended.expression);
}
if (baseConstructorType.flags & (TypeFlags.Object | TypeFlags.Intersection)) {
// Resolving the members of a class requires us to resolve the base class of that class.
// We force resolution here such that we catch circularities now.