Skip to content

Commit f0e70cb

Browse files
RyanCavanaughbillti
authored andcommitted
Don't crash when return type jsdoc tag is malformed
Fixes #6662 (cherry picked from commit 5a845bf)
1 parent c6e18a9 commit f0e70cb

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
@@ -10356,7 +10356,7 @@ namespace ts {
1035610356

1035710357
function getReturnTypeFromJSDocComment(func: SignatureDeclaration | FunctionDeclaration): Type {
1035810358
const returnTag = getJSDocReturnTag(func);
10359-
if (returnTag) {
10359+
if (returnTag && returnTag.typeExpression) {
1036010360
return getTypeFromTypeNode(returnTag.typeExpression.type);
1036110361
}
1036210362
}
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)