docs-util: created docblock-generator tool (#6096)

This commit is contained in:
Shahed Nasser
2024-01-24 11:13:40 +01:00
committed by GitHub
parent d68089b2aa
commit f29948a6a8
37 changed files with 2684 additions and 115 deletions
@@ -0,0 +1,24 @@
import ts from "typescript"
/**
* Retrieves the symbol of a node.
*
* @param {ts.Node} node - The node to retrieve its symbol.
* @param {ts.TypeChecker} checker - The type checker of the TypeScript program the symbol is in.
* @returns {ts.Symbol | undefined} The symbol if found.
*/
export default function getSymbol(
node: ts.Node,
checker: ts.TypeChecker
): ts.Symbol | undefined {
if (
ts.isVariableStatement(node) &&
node.declarationList.declarations.length
) {
return getSymbol(node.declarationList.declarations[0], checker)
}
return "symbol" in node && node.symbol
? (node.symbol as ts.Symbol)
: undefined
}