jsdoc-scribe API/lib/ast-utilsCurrent
Functions(6)
#getDescendantsOfKind
line 27
Collect every descendant of `node` whose `kind` equals `kind`. Unconditional full descent -- does NOT stop at function-like boundaries. Callers that need boundary-stopping behavior (e.g. "only look inside this function, not nested ones") should use `findFirstDescendant` with a predicate that encodes that boundary instead. depth-first document order. Empty array if none found.
ParameterTypeOptionalDescription
nodeimport("typescript").Node- Root node to search from.
kindimport("typescript").SyntaxKind- The SyntaxKind to match.
Returns: import("typescript").Node[] — All matching descendants, in
Signature
getDescendantsOfKind(node: any, kind: any): any
ParameterTypeOptionalDescription
nany
Signature
walk(n: any)
#findFirstDescendant
line 55
Depth-first search for the first descendant of `node` matching `predicate`. Short-circuits on first match -- does not continue walking siblings/children once found. An optional `stopAt` predicate lets the caller prune descent into a subtree (checked only when `predicate` did not already match on that same node) -- e.g. to stop at nested function boundaries the way `extractor.js`'s original `hasReturnWithValue` did. Omit it for unconditional full descent. a non-matching node, its children are not visited. `undefined` if none found.
ParameterTypeOptionalDescription
nodeimport("typescript").Node- Root node to search from.
predicate(n: import("typescript").Node) => boolean- Match test.
stopAt(n: import("typescript").Node) => booleanyes- When true for
Returns: import("typescript").Node|undefined — The first matching node, or
Signature
findFirstDescendant(node: any, predicate: any, stopAt: any): any
ParameterTypeOptionalDescription
nany
Signature
walk(n: any)
#asClass
line 75
Narrow `node` to a class declaration, or return `null`. Thin wrapper over `ts.isClassDeclaration` -- exists purely to cut the `ts.isClassDeclaration(node) ? node : null` boilerplate at call sites.
ParameterTypeOptionalDescription
nodeimport("typescript").Node- Node to test.
Returns: import("typescript").ClassDeclaration|null
Signature
asClass(node: any): any
#asFunctionLike
line 88
Narrow `node` to a function-like expression, or return `null`. Matches exactly the set lib/extractor.js's own `isFunctionLike()` already treats as function-like: arrow functions and function expressions (NOT function declarations, which extractor.js handles as a separate case).
ParameterTypeOptionalDescription
nodeimport("typescript").Node- Node to test.
Returns: import("typescript").ArrowFunction|import("typescript").FunctionExpression|null
Signature
asFunctionLike(node: any): any
Variables & Constants(3)
const ts: any
const
Signature
const ts: any
#results
line 28
const results: Array
const
Signature
const results: Array
let found: any
var
Signature
let found: any