docs-util: created docblock-generator tool (#6096)
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user