You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** * First */constfirstVariable=true,/** * Second */secondVariable=false;
import{getJsDoc}from"tsutils";// Edit: not visitVariableStatement(node: VariableStatement)functionvisitVariableDeclaration(node: VariableDeclaration){// BlankgetJsDoc(node);// Always ["First"]getJsDoc(node.parent);}
Expected:
Calling getJsDoc on a VariableStatement should retrieve the docs for the node, even if they're also the docs for the containing VariableDeclarationList.
Actual:
Only ever gets the docs for the VariableDeclarationList.
The text was updated successfully, but these errors were encountered:
I think you mixed up VariableStatement and VariableDeclarationList in your example.
VariableDeclarationList never has any JSDoc, because it is located on the VariableStatement.
This function is not intended to find the JSDoc on any parent node. It's just a thin wrapper to make the internal property Node.jsDoc available to use in your program.
TypeScript never parses JSDoc on VariableDeclaration or VariableDeclarationList. You need to take care of passing the correct node to the function.
If there is the need for a function that retrieves JSDoc for a node the way TypeScript does, I can probably add that on top.
You throw in any Node / (Named)Declaration and get back the JSDoc TypeScript would use?
Should it automatically search for JSDoc on the opposite property accessor?
IMO yes, but with the caveat that it only looks at the single file (no class inheritance checks or the like). Other than that get/set edge case, and parsing through variable statement/declaration/declaration lists, I can't think of other edge cases.
Expected:
Calling
getJsDoc
on aVariableStatement
should retrieve the docs for the node, even if they're also the docs for the containingVariableDeclarationList
.Actual:
Only ever gets the docs for the
VariableDeclarationList
.The text was updated successfully, but these errors were encountered: