@@ -5392,16 +5392,7 @@ namespace ts {
5392
5392
}
5393
5393
5394
5394
function getBaseTypeNodeOfClass(type: InterfaceType): ExpressionWithTypeArguments | undefined {
5395
- const decl = <ClassLikeDeclaration>type.symbol.valueDeclaration;
5396
- if (isInJavaScriptFile(decl)) {
5397
- // Prefer an @augments tag because it may have type parameters.
5398
- const tag = getJSDocAugmentsTag(decl);
5399
- if (tag) {
5400
- return tag.class;
5401
- }
5402
- }
5403
-
5404
- return getClassExtendsHeritageClauseElement(decl);
5395
+ return getEffectiveBaseTypeNode(type.symbol.valueDeclaration as ClassLikeDeclaration);
5405
5396
}
5406
5397
5407
5398
function getConstructorsForTypeArguments(type: Type, typeArgumentNodes: ReadonlyArray<TypeNode> | undefined, location: Node): Signature[] {
@@ -5428,7 +5419,7 @@ namespace ts {
5428
5419
function getBaseConstructorTypeOfClass(type: InterfaceType): Type {
5429
5420
if (!type.resolvedBaseConstructorType) {
5430
5421
const decl = <ClassLikeDeclaration>type.symbol.valueDeclaration;
5431
- const extended = getClassExtendsHeritageClauseElement (decl);
5422
+ const extended = getEffectiveBaseTypeNode (decl);
5432
5423
const baseTypeNode = getBaseTypeNodeOfClass(type);
5433
5424
if (!baseTypeNode) {
5434
5425
return type.resolvedBaseConstructorType = undefinedType;
@@ -14764,7 +14755,7 @@ namespace ts {
14764
14755
14765
14756
function checkThisBeforeSuper(node: Node, container: Node, diagnosticMessage: DiagnosticMessage) {
14766
14757
const containingClassDecl = <ClassDeclaration>container.parent;
14767
- const baseTypeNode = getClassExtendsHeritageClauseElement (containingClassDecl);
14758
+ const baseTypeNode = getEffectiveBaseTypeNode (containingClassDecl);
14768
14759
14769
14760
// If a containing class does not have extends clause or the class extends null
14770
14761
// skip checking whether super statement is called before "this" accessing.
@@ -15040,7 +15031,7 @@ namespace ts {
15040
15031
15041
15032
// at this point the only legal case for parent is ClassLikeDeclaration
15042
15033
const classLikeDeclaration = <ClassLikeDeclaration>container.parent;
15043
- if (!getClassExtendsHeritageClauseElement (classLikeDeclaration)) {
15034
+ if (!getEffectiveBaseTypeNode (classLikeDeclaration)) {
15044
15035
error(node, Diagnostics.super_can_only_be_referenced_in_a_derived_class);
15045
15036
return errorType;
15046
15037
}
@@ -18678,7 +18669,7 @@ namespace ts {
18678
18669
if (superType !== errorType) {
18679
18670
// In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated
18680
18671
// with the type arguments specified in the extends clause.
18681
- const baseTypeNode = getClassExtendsHeritageClauseElement (getContainingClass(node)!);
18672
+ const baseTypeNode = getEffectiveBaseTypeNode (getContainingClass(node)!);
18682
18673
if (baseTypeNode) {
18683
18674
const baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode);
18684
18675
return resolveCall(node, baseConstructors, candidatesOutArray);
@@ -21474,7 +21465,7 @@ namespace ts {
21474
21465
// Constructors of classes with no extends clause may not contain super calls, whereas
21475
21466
// constructors of derived classes must contain at least one super call somewhere in their function body.
21476
21467
const containingClassDecl = <ClassDeclaration>node.parent;
21477
- if (getClassExtendsHeritageClauseElement (containingClassDecl)) {
21468
+ if (getEffectiveBaseTypeNode (containingClassDecl)) {
21478
21469
captureLexicalThis(node.parent, containingClassDecl);
21479
21470
const classExtendsNull = classDeclarationExtendsNull(containingClassDecl);
21480
21471
const superCall = getSuperCallInConstructor(node);
@@ -22651,7 +22642,7 @@ namespace ts {
22651
22642
}
22652
22643
22653
22644
const name = getIdentifierFromEntityNameExpression(node.class.expression);
22654
- const extend = getClassExtendsHeritageClauseElement (classLike);
22645
+ const extend = getClassExtendsHeritageElement (classLike);
22655
22646
if (extend) {
22656
22647
const className = getIdentifierFromEntityNameExpression(extend.expression);
22657
22648
if (className && name.escapedText !== className.escapedText) {
@@ -24426,7 +24417,7 @@ namespace ts {
24426
24417
checkClassForStaticPropertyNameConflicts(node);
24427
24418
}
24428
24419
24429
- const baseTypeNode = getClassExtendsHeritageClauseElement (node);
24420
+ const baseTypeNode = getEffectiveBaseTypeNode (node);
24430
24421
if (baseTypeNode) {
24431
24422
if (languageVersion < ScriptTarget.ES2015) {
24432
24423
checkExternalEmitHelpers(baseTypeNode.parent, ExternalEmitHelpers.Extends);
@@ -24439,6 +24430,10 @@ namespace ts {
24439
24430
const staticBaseType = getApparentType(baseConstructorType);
24440
24431
checkBaseTypeAccessibility(staticBaseType, baseTypeNode);
24441
24432
checkSourceElement(baseTypeNode.expression);
24433
+ const extendsNode = getClassExtendsHeritageElement(node);
24434
+ if (extendsNode && extendsNode !== baseTypeNode) {
24435
+ checkExpression(extendsNode.expression);
24436
+ }
24442
24437
if (some(baseTypeNode.typeArguments)) {
24443
24438
forEach(baseTypeNode.typeArguments, checkSourceElement);
24444
24439
for (const constructor of getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode)) {
0 commit comments