Skip to content

Commit 17f10c0

Browse files
author
Andy
authored
Fix crash when @Augments tag has no type (#18739)
1 parent a4cf79b commit 17f10c0

File tree

5 files changed

+73
-1
lines changed

5 files changed

+73
-1
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4990,7 +4990,7 @@ namespace ts {
49904990
const valueDecl = type.symbol.valueDeclaration;
49914991
if (valueDecl && isInJavaScriptFile(valueDecl)) {
49924992
const augTag = getJSDocAugmentsTag(type.symbol.valueDeclaration);
4993-
if (augTag) {
4993+
if (augTag && augTag.typeExpression && augTag.typeExpression.type) {
49944994
baseType = getTypeFromTypeNode(augTag.typeExpression.type);
49954995
}
49964996
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/a.js(2,14): error TS1005: '{' expected.
2+
3+
4+
==== /a.js (1 errors) ====
5+
class A { constructor() { this.x = 0; } }
6+
/** @augments */
7+
~
8+
!!! error TS1005: '{' expected.
9+
class B extends A {
10+
m() {
11+
this.x
12+
}
13+
}
14+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
=== /a.js ===
2+
class A { constructor() { this.x = 0; } }
3+
>A : Symbol(A, Decl(a.js, 0, 0))
4+
>this.x : Symbol(A.x, Decl(a.js, 0, 25))
5+
>this : Symbol(A, Decl(a.js, 0, 0))
6+
>x : Symbol(A.x, Decl(a.js, 0, 25))
7+
8+
/** @augments */
9+
class B extends A {
10+
>B : Symbol(B, Decl(a.js, 0, 41))
11+
>A : Symbol(A, Decl(a.js, 0, 0))
12+
13+
m() {
14+
>m : Symbol(B.m, Decl(a.js, 2, 19))
15+
16+
this.x
17+
>this.x : Symbol(A.x, Decl(a.js, 0, 25))
18+
>this : Symbol(B, Decl(a.js, 0, 41))
19+
>x : Symbol(A.x, Decl(a.js, 0, 25))
20+
}
21+
}
22+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
=== /a.js ===
2+
class A { constructor() { this.x = 0; } }
3+
>A : A
4+
>this.x = 0 : 0
5+
>this.x : number
6+
>this : this
7+
>x : number
8+
>0 : 0
9+
10+
/** @augments */
11+
class B extends A {
12+
>B : B
13+
>A : A
14+
15+
m() {
16+
>m : () => void
17+
18+
this.x
19+
>this.x : number
20+
>this : this
21+
>x : number
22+
}
23+
}
24+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// @allowJs: true
2+
// @checkJs: true
3+
// @noEmit: true
4+
5+
// @Filename: /a.js
6+
class A { constructor() { this.x = 0; } }
7+
/** @augments */
8+
class B extends A {
9+
m() {
10+
this.x
11+
}
12+
}

0 commit comments

Comments
 (0)