Skip to content

Commit 5a845bf

Browse files
committed
Don't crash when return type jsdoc tag is malformed
Fixes #6662
1 parent 2ef6f13 commit 5a845bf

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/compiler/checker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10344,7 +10344,7 @@ namespace ts {
1034410344

1034510345
function getReturnTypeFromJSDocComment(func: SignatureDeclaration | FunctionDeclaration): Type {
1034610346
const returnTag = getJSDocReturnTag(func);
10347-
if (returnTag) {
10347+
if (returnTag && returnTag.typeExpression) {
1034810348
return getTypeFromTypeNode(returnTag.typeExpression.type);
1034910349
}
1035010350
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @allowNonTsExtensions: true
4+
// @Filename: file.js
5+
//// /**
6+
//// * This is a very cool function that is very nice.
7+
//// * @returns something
8+
//// */
9+
//// function a1() {
10+
//// try {
11+
//// throw new Error('x');
12+
//// } catch (x) { x--; }
13+
//// return 23;
14+
//// }
15+
////
16+
//// x - /**/a1()
17+
18+
goTo.marker();
19+
verify.quickInfoExists();

0 commit comments

Comments
 (0)