Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2513,14 +2513,15 @@ namespace ts {
}

export function getEffectiveBaseTypeNode(node: ClassLikeDeclaration | InterfaceDeclaration) {
if (isInJSFile(node)) {
const baseType = getClassExtendsHeritageElement(node);
if (baseType && isInJSFile(node)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DanielRosenwasser @sandersn should it be error to have augments clause and not have extends clause?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be too noisy. Every time we add errors like this they add noise to erroneous jsdoc -- ones where people weren't actually using the jsdoc and didn't want to.

// 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) {
Expand Down
15 changes: 15 additions & 0 deletions tests/baselines/reference/jsdocAugments_noExtends.errors.txt
Original file line number Diff line number Diff line change
@@ -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'.
}
}

2 changes: 0 additions & 2 deletions tests/baselines/reference/jsdocAugments_noExtends.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

6 changes: 3 additions & 3 deletions tests/baselines/reference/jsdocAugments_noExtends.types
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}