Fix crash when @augments tag has no type (#18739)
This commit is contained in:
parent
a4cf79baa5
commit
17f10c032e
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
tests/baselines/reference/jsdocAugmentsMissingType.symbols
Normal file
22
tests/baselines/reference/jsdocAugmentsMissingType.symbols
Normal 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))
|
||||
}
|
||||
}
|
||||
|
24
tests/baselines/reference/jsdocAugmentsMissingType.types
Normal file
24
tests/baselines/reference/jsdocAugmentsMissingType.types
Normal 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
|
||||
}
|
||||
}
|
||||
|
12
tests/cases/compiler/jsdocAugmentsMissingType.ts
Normal file
12
tests/cases/compiler/jsdocAugmentsMissingType.ts
Normal 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
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue