getEffectiveBaseTypeNode: only use JSDoc augments if there is extends (#29349)

This commit is contained in:
Klaus Meinhardt
2019-02-06 00:51:55 +01:00
committed by Nathan Shively-Sanders
parent 7c096576bc
commit 12edac0925
4 changed files with 21 additions and 7 deletions

View File

@@ -2514,14 +2514,15 @@ namespace ts {
}
export function getEffectiveBaseTypeNode(node: ClassLikeDeclaration | InterfaceDeclaration) {
if (isInJSFile(node)) {
const baseType = getClassExtendsHeritageElement(node);
if (baseType && isInJSFile(node)) {
// Prefer an @augments tag because it may have type parameters.
const tag = getJSDocAugmentsTag(node);
if (tag) {
return tag.class;
}
}
return getClassExtendsHeritageElement(node);
return baseType;
}
export function getClassExtendsHeritageElement(node: ClassLikeDeclaration | InterfaceDeclaration) {

View File

@@ -0,0 +1,15 @@
/b.js(6,21): error TS2339: Property 'x' does not exist on type 'B'.
==== /b.js (1 errors) ====
class A { constructor() { this.x = 0; } }
/** @augments A */
class B {
m() {
return this.x;
~
!!! error TS2339: Property 'x' does not exist on type 'B'.
}
}

View File

@@ -13,9 +13,7 @@ class B {
>m : Symbol(B.m, Decl(b.js, 3, 9))
return this.x;
>this.x : Symbol(A.x, Decl(b.js, 0, 25))
>this : Symbol(B, Decl(b.js, 0, 41))
>x : Symbol(A.x, Decl(b.js, 0, 25))
}
}

View File

@@ -12,12 +12,12 @@ class B {
>B : B
m() {
>m : () => number
>m : () => any
return this.x;
>this.x : number
>this.x : any
>this : this
>x : number
>x : any
}
}