Skip to content

⬅️ Back to Table of Contents

📄 getDeclaration

📊 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

Gets the declaration for the given variable

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

Calls:

  • services.getSymbolAtLocation
  • symbol.getDeclarations
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;
}

Generated by Syntax Scribe