Skip to content

Fix crash when @augments tag has no type #18739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
1 commit merged into from
Sep 25, 2017
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
2 changes: 1 addition & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4990,7 +4990,7 @@ namespace ts {
const valueDecl = type.symbol.valueDeclaration;
if (valueDecl && isInJavaScriptFile(valueDecl)) {
const augTag = getJSDocAugmentsTag(type.symbol.valueDeclaration);
if (augTag) {
if (augTag && augTag.typeExpression && augTag.typeExpression.type) {
baseType = getTypeFromTypeNode(augTag.typeExpression.type);
}
}
Expand Down
14 changes: 14 additions & 0 deletions tests/baselines/reference/jsdocAugmentsMissingType.errors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/a.js(2,14): error TS1005: '{' expected.


==== /a.js (1 errors) ====
class A { constructor() { this.x = 0; } }
/** @augments */
~
!!! error TS1005: '{' expected.
class B extends A {
m() {
this.x
}
}

22 changes: 22 additions & 0 deletions tests/baselines/reference/jsdocAugmentsMissingType.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
=== /a.js ===
class A { constructor() { this.x = 0; } }
>A : Symbol(A, Decl(a.js, 0, 0))
>this.x : Symbol(A.x, Decl(a.js, 0, 25))
>this : Symbol(A, Decl(a.js, 0, 0))
>x : Symbol(A.x, Decl(a.js, 0, 25))

/** @augments */
class B extends A {
>B : Symbol(B, Decl(a.js, 0, 41))
>A : Symbol(A, Decl(a.js, 0, 0))

m() {
>m : Symbol(B.m, Decl(a.js, 2, 19))

this.x
>this.x : Symbol(A.x, Decl(a.js, 0, 25))
>this : Symbol(B, Decl(a.js, 0, 41))
>x : Symbol(A.x, Decl(a.js, 0, 25))
}
}

24 changes: 24 additions & 0 deletions tests/baselines/reference/jsdocAugmentsMissingType.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
=== /a.js ===
class A { constructor() { this.x = 0; } }
>A : A
>this.x = 0 : 0
>this.x : number
>this : this
>x : number
>0 : 0

/** @augments */
class B extends A {
>B : B
>A : A

m() {
>m : () => void

this.x
>this.x : number
>this : this
>x : number
}
}

12 changes: 12 additions & 0 deletions tests/cases/compiler/jsdocAugmentsMissingType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// @allowJs: true
// @checkJs: true
// @noEmit: true

// @Filename: /a.js
class A { constructor() { this.x = 0; } }
/** @augments */
class B extends A {
m() {
this.x
}
}