Skip to content

⬅️ Back to Table of Contents

📄 getDeclaration.ts

📊 Analysis Summary

Metric Count
🔧 Functions 1
📦 Imports 2

📚 Table of Contents

🛠️ File Location:

📂 packages/type-utils/src/getDeclaration.ts

📦 Imports

Name Source
ParserServicesWithTypeInformation @typescript-eslint/typescript-estree
TSESTree @typescript-eslint/typescript-estree

Functions

getDeclaration(services: ParserServicesWithTypeInformation, node: TSESTree.Node): ts.Declaration | null

Code
export function getDeclaration(
  services: ParserServicesWithTypeInformation,
  node: TSESTree.Node,
): ts.Declaration | null {
  const symbol = services.getSymbolAtLocation(node);
  if (!symbol) {
    return null;
  }
  const declarations = symbol.getDeclarations();
  return declarations?.[0] ?? null;
}
  • JSDoc:

    /**
     * Gets the declaration for the given variable
     */
    

  • Parameters:

  • services: ParserServicesWithTypeInformation
  • node: TSESTree.Node
  • Return Type: ts.Declaration | null
  • Calls:
  • services.getSymbolAtLocation
  • symbol.getDeclarations