Don't crash when return type jsdoc tag is malformed

Fixes #6662

(cherry picked from commit 5a845bf0fca604a9928ec8762266231ec62fafda)
This commit is contained in:
Ryan Cavanaugh 2016-01-28 15:48:18 -08:00 committed by Bill Ticehurst
parent c6e18a9fcf
commit f0e70cbf0f
2 changed files with 20 additions and 1 deletions

View File

@ -10356,7 +10356,7 @@ namespace ts {
function getReturnTypeFromJSDocComment(func: SignatureDeclaration | FunctionDeclaration): Type {
const returnTag = getJSDocReturnTag(func);
if (returnTag) {
if (returnTag && returnTag.typeExpression) {
return getTypeFromTypeNode(returnTag.typeExpression.type);
}
}

View File

@ -0,0 +1,19 @@
/// <reference path="fourslash.ts" />
// @allowNonTsExtensions: true
// @Filename: file.js
//// /**
//// * This is a very cool function that is very nice.
//// * @returns something
//// */
//// function a1() {
//// try {
//// throw new Error('x');
//// } catch (x) { x--; }
//// return 23;
//// }
////
//// x - /**/a1()
goTo.marker();
verify.quickInfoExists();