Skip to content
RAGRAF

TypeScript, JavaScript and Astro

What the index treats as a fact in TypeScript and Astro: symbols from arrow functions and type aliases, call binding by the import line, dead_code honesty, the .astro extractor and the named gap.

Updated: 2026-11-23

What became a symbol #

ConstructSymbol
function f() {}function
const f = () => {}function
const f = function () {}function
const g = function* () {}function
const port = 8080none: the value is not functional
type Id = string | numbertype_alias

Two fields instead of one (function_values, type_aliases) exist because "every variable declaration is a function" would turn a constant into a symbol with no calls, and dead_code would receive a false target.

How a cross-file call is bound #

A call the extractor could not resolve becomes an @ext:<name> placeholder. A post-pass of the indexer reads the import lines and replaces the placeholder with an edge to the real definition:

  • evidence_kind="import", provenance="derived", confidence 0.9;
  • the evidence address path:line is taken from the placeholder being replaced —

exactly where the call is written;

  • package specifiers (react, @scope/pkg) are not bound: there is no file;
  • tsconfig.paths aliases are not supported — a named gap, not a quiet guess;
  • the same pass creates an imports edge file → file, and it counts as an

incoming reference for dead_code.

Shell
ragraf query callers --name renderDashboard

The answer carries the kind of the edge (import), the confidence and the call address, so it can be checked.

dead_code: the verdict and the unproven #

The answer keeps two lists apart:

  • files — the verdict: no references at all, including no incoming imports;
  • unproven — files whose calls could not be bound

(evidence_kind="external_call"). "No reference" and "the reference was not built" are different facts, so such files never reach the verdict: the call names and the reason are named, and the count is in unproven_count.

Do not delete code on a hint while unproven is not empty.

Astro #

.astro files are indexed: the frontmatter and every <script> block are parsed as TypeScript with the markup masked, so path:line points at the real line of the page. Markup does not become symbols — a template is not a call graph. The astro format is a registry entry: visible and switchable in the panel, and when disabled it counts in skipped_formats.

Where the index lives, and a protected directory #

The index is .ragraf/ inside the project root, and it is not a setting: the corpus checksum and the /.ragraf/ self-exclusion are computed from that root. If the directory cannot be written, ragraf index stops with exit code 3 and names the reason, instead of failing inside sqlite with "file does not exist". Index a copy of the project in a writable location.

How this is verified #

CheckWhat it holds
tests/test_client_report.py30 properties: TS symbols, import binding, dead_code, Astro and line numbers, index_status, db.enabled, journal kind, neighbors with two corpora, damaged registry
tests/test_drift_restore.py8 properties: change, warning, file restored, warning withdrawn, journal preserved
tests/test_lang_routing.py, tests/test_new_languages.pythe set of parsed languages agrees with the profiles
tests/test_formats.pyevery extension of the language map belongs to a format