-
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
Conversation
@@ -10344,7 +10344,7 @@ 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explicitly return undefined
?
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.
Or should you be returning the unknownType
instead?
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.
undefined is fine.
//// x - /**/a1() | ||
|
||
goTo.marker(); | ||
verify.quickInfoExists(); |
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Verified manually since Fourslash is currently really bad at that
Couple of minor comments, else 👍 |
👍 |
Don't crash when return type jsdoc tag is malformed
Fixes #6662