-
Notifications
You must be signed in to change notification settings - Fork 13k
Check JSDoc @param
tag names
#18777
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
Check JSDoc @param
tag names
#18777
Conversation
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.
I don't think there should be an error in Typescript, or in cases where there is no typeExpression. Well, they should be warnings, if we had such things already.
Either way, I'd like to see tests for these cases.
function checkJSDocParameterTag(node: JSDocParameterTag) { | ||
checkSourceElement(node.typeExpression); | ||
if (!getParameterSymbolFromJSDoc(node)) { | ||
error(node.name, |
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.
This should be a lint-style warning if there is no typeExpression, or if the typeExpression is ignored, the way it is in Typescript.
Until we have a warning infrastructure, I would rather not issue the error in those two cases.
@@ -19789,6 +19789,15 @@ namespace ts { | |||
} | |||
} | |||
|
|||
function checkJSDocParameterTag(node: JSDocParameterTag) { | |||
checkSourceElement(node.typeExpression); | |||
if (!getParameterSymbolFromJSDoc(node)) { |
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.
getParameterSymbolFromJSDoc
has a linear search of function.parameters
, and we call this for every @param
node. So it's quadratic where it could be linear if we wrote sufficiently clever code.
Might not be an issue, but I wanted to make sure you'd thought about it. (Most functions have few parameters and most @params
are correct, so pathological cases should be rare.)
@sandersn Based on our discussion I think all of these points can be dealt with later? I could start working on performance tomorrow if this got in today.
|
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.
Yep, sounds good to me.
Related: #15852, but that's a broader issue so this won't fix it completely.