Fix crash when @augments tag has no type (#18739)

This commit is contained in:
Andy 2017-09-25 09:58:46 -07:00 committed by GitHub
parent a4cf79baa5
commit 17f10c032e
5 changed files with 73 additions and 1 deletions

View file

@ -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);
}
}

View file

@ -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
}
}

View file

@ -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))
}
}

View file

@ -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
}
}

View file

@ -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
}
}