@@ -9,14 +9,10 @@ export function docs(node: Node): string[] {
99}
1010
1111function nodesWithDocs ( node : Node ) : Node [ ] {
12- // A node may not have the jsdoc comment directly attached to it in the AST.
13- // Let's find the nodes that do so starting from the given node.
14- if ( Node . isVariableDeclaration ( node ) ) {
15- return [ node . getVariableStatementOrThrow ( ) ] ;
16- }
17- if ( Node . isExpression ( node ) ) {
18- return [ node . getParent ( ) ! ] ;
19- }
12+ // A node may not have a JSDoc comment directly attached to it in the AST.
13+ // Find the nodes that have the attached comment starting from the given node.
14+ if ( Node . isVariableDeclaration ( node ) ) return [ node . getVariableStatementOrThrow ( ) ] ;
15+ if ( Node . isExpression ( node ) ) return [ node . getParent ( ) ! ] ;
2016 if ( Node . isOverloadable ( node ) && ! Node . isConstructorDeclaration ( node ) ) {
2117 // Functions and class methods can be overloaded with each declaration
2218 // having its own doc. Since we return overloaded declarations grouped
@@ -30,7 +26,7 @@ function nodesWithDocs(node: Node): Node[] {
3026 Node . isMethodSignature ( node ) &&
3127 node . getParent ( ) . getKind ( ) === SyntaxKind . InterfaceDeclaration
3228 ) {
33- // Treat interface methods like overloadable class methods above .
29+ // Treat interface methods like overloaded class methods.
3430 const methodName = node . getName ( ) ;
3531 const overloads = node
3632 . getParentIfKindOrThrow ( SyntaxKind . InterfaceDeclaration )
@@ -42,12 +38,12 @@ function nodesWithDocs(node: Node): Node[] {
4238}
4339
4440function lastDoc ( node : Node ) : string | undefined {
45- // Get the jsdoc comment closest to the node.
41+ // Get the JSDoc comment closest to the node.
4642 const doc = node . getLastChildByKind ( SyntaxKind . JSDoc ) ?. getText ( ) ;
4743 if ( ! doc ) return undefined ;
4844 if ( parseDocComment ( doc ) . modifierTagSet . isPackageDocumentation ( ) ) {
49- // The first declaration after package documentation should not
50- // inherit that unrelated jsdoc comment if it has none itself .
45+ // The first declaration after the package documentation comment
46+ // should not use that comment for its own documentation .
5147 // See `export-named-declaration-without-jsdoc.test.ts`.
5248 return undefined ;
5349 }
0 commit comments