mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 04:43:37 -05:00
getEffectiveBaseTypeNode: only use JSDoc augments if there is extends (#29349)
This commit is contained in:
committed by
Nathan Shively-Sanders
parent
7c096576bc
commit
12edac0925
@@ -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) {
|
||||
|
||||
15
tests/baselines/reference/jsdocAugments_noExtends.errors.txt
Normal file
15
tests/baselines/reference/jsdocAugments_noExtends.errors.txt
Normal 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'.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user