-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Don't crash when return type jsdoc tag is malformed #6709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10344,9 +10344,11 @@ namespace ts { | |
|
||
function getReturnTypeFromJSDocComment(func: SignatureDeclaration | FunctionDeclaration): Type { | ||
const returnTag = getJSDocReturnTag(func); | ||
if (returnTag) { | ||
if (returnTag && returnTag.typeExpression) { | ||
return getTypeFromTypeNode(returnTag.typeExpression.type); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you explicitly return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or should you be returning the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. undefined is fine. |
||
|
||
return undefined; | ||
} | ||
|
||
function createPromiseType(promisedType: Type): Type { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @allowNonTsExtensions: true | ||
// @Filename: file.js | ||
//// /** | ||
//// * This is a very cool function that is very nice. | ||
//// * @returns something | ||
//// * @param p anotherthing | ||
//// */ | ||
//// function a1(p) { | ||
//// try { | ||
//// throw new Error('x'); | ||
//// } catch (x) { x--; } | ||
//// return 23; | ||
//// } | ||
//// | ||
//// x - /**/a1() | ||
|
||
goTo.marker(); | ||
verify.quickInfoExists(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we also verify that the quickinfo still correctly contains the first line of the comment? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Verified manually since Fourslash is currently really bad at that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have tests for malformed types in other tags (e.g.
@param
)?