declarationOf

tcmts.core.ir.declarationOf · #6djkabiy · term · runs anywhere

A definition's declaration: its VariableDeclaration (a const, a let, a binding of a destructuring), ClassDeclaration, InterfaceDeclaration…; an overloaded function's implementation.

import type { IR } from "#codebase/tcmts/core/hash";
import { defParts } from "#codebase/tcmts/core/ir";

export function declarationOf(ir: IR[] | string): IR[] | undefined {
  const d = defParts(ir).body.at(-1);
  return Array.isArray(d) ? d : undefined;
}

uses

used by