Skip to content

fix: export enum declarations now produce an Export record - #2586

Open
carlos-alm wants to merge 1 commit into
mainfrom
fix/issue-2560
Open

fix: export enum declarations now produce an Export record#2586
carlos-alm wants to merge 1 commit into
mainfrom
fix/issue-2560

Conversation

@carlos-alm

Copy link
Copy Markdown
Contributor

Summary

  • Discovered while investigating tree-sitter-javascript misparses bare export + newline before a declaration — export silently dropped entirely #2459. export enum Foo {} is correctly parsed as an export_statement wrapping an enum_declaration in both engines, but the export-collection logic that turns a wrapped declaration into an Export record had no case for enum_declaration — it silently fell through to a no-op. The enum's Definition was still created (via handleEnumDecl/handle_enum_decl), just never marked exported=1.
  • Both engines agreed with each other (not a cross-engine parity gap) but were both wrong relative to real JS/TS semantics: export enum Foo {} genuinely exports Foo.
  • Fix: added enum_declaration: 'enum' to EXPORT_DECL_KIND in src/extractors/javascript.ts, and "enum_declaration" => ("enum", "name"), to handle_export_declaration's match in crates/codegraph-core/src/extractors/javascript.rs — the exact existing pattern already used for function/class/interface/type declarations, since both engines already build the enum's own Definition with kind: 'enum' from the same node's name/line.
  • Both TS's collectExportedDeclarations and Rust's handle_export_declaration are each single, shared functions across all their respective call sites, so this is a genuinely one-point fix per engine (no risk of the "two code paths" extractor gotcha).

Closes #2560

Test plan

  • New tests in tests/parsers/javascript.test.ts (TS/WASM path) and crates/codegraph-core/src/extractors/javascript.rs (native path): an exported enum produces both a Definition (kind enum) and an Export (kind enum) at the correct line; a non-exported enum still gets a Definition but no Export.
  • Revert-verify (both engines independently): temporarily removed each fix and confirmed the corresponding new test fails with exactly the pre-fix symptom (empty exports array); restored both and all pass again.
  • End-to-end verification beyond the extractor-unit level: built a real fixture with codegraph build --engine wasm and --engine native (rebuilding the native addon from this branch's Rust source) — codegraph exports correctly lists the exported enum and correctly omits the non-exported one, for both engines.
  • cargo fmt -- --check and cargo test --lib extractors::javascript (328/328) clean.
  • npm run lint clean.
  • Full npx vitest run: 5534/5534 tests pass (344 test files, +2 new).

enum_declaration was extracted as a Definition (via handleEnumDecl/
handle_enum_decl) but had no case in EXPORT_DECL_KIND (TS) or
handle_export_declaration's match (Rust), so export enum Foo {} never
produced an Export entry in either engine -- the enum itself was silently
treated as internal, even though real JS/TS semantics say it's exported.
Both engines already build the enum's own Definition with kind 'enum' via
the same node's name/line, so this is a one-line addition per engine using
the exact existing pattern already used for function/class/interface/type
declarations.

Verified end-to-end (not just at the extractor-unit level): built a real
fixture with `codegraph build --engine wasm` and `--engine native`
(rebuilding the native addon from this branch's Rust source) -- both now
correctly show the exported enum via `codegraph exports`, and correctly
still omit a non-exported one.

Closes #2560

docs check acknowledged
@greptile-apps

greptile-apps Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR makes exported TypeScript enum declarations produce matching Export records in both extraction engines.

  • Adds enum_declaration handling to the TypeScript/WASM export collector.
  • Mirrors the enum export classification in the native Rust extractor.
  • Adds positive and negative regression coverage for exported and non-exported enums.

Confidence Score: 5/5

The PR appears safe to merge, with native and WASM enum export handling aligned and covered by focused regression tests.

The new mappings use the same enum name, kind, and declaration line as the existing Definition handlers, and both extraction engines apply the equivalent change through their shared export-collection paths.

Important Files Changed

Filename Overview
crates/codegraph-core/src/extractors/javascript.rs Adds native enum export classification with name, kind, and line values matching the existing enum Definition, plus regression tests.
src/extractors/javascript.ts Adds enum declarations to the shared export-kind table used by both TypeScript extraction paths.
tests/parsers/javascript.test.ts Verifies exported enums produce matching Definition and Export records while non-exported enums remain unexported.

Reviews (1): Last reviewed commit: "fix: export enum declarations now produc..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

export enum declarations never produce an Export record, in either engine

1 participant