fix: export enum declarations now produce an Export record - #2586
Open
carlos-alm wants to merge 1 commit into
Open
fix: export enum declarations now produce an Export record#2586carlos-alm wants to merge 1 commit into
carlos-alm wants to merge 1 commit into
Conversation
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
Contributor
Greptile SummaryThis PR makes exported TypeScript enum declarations produce matching Export records in both extraction engines.
Confidence Score: 5/5The 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
Reviews (1): Last reviewed commit: "fix: export enum declarations now produc..." | Re-trigger Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
export+ newline before a declaration — export silently dropped entirely #2459.export enum Foo {}is correctly parsed as anexport_statementwrapping anenum_declarationin both engines, but the export-collection logic that turns a wrapped declaration into anExportrecord had no case forenum_declaration— it silently fell through to a no-op. The enum'sDefinitionwas still created (viahandleEnumDecl/handle_enum_decl), just never markedexported=1.export enum Foo {}genuinely exportsFoo.enum_declaration: 'enum'toEXPORT_DECL_KINDinsrc/extractors/javascript.ts, and"enum_declaration" => ("enum", "name"),tohandle_export_declaration's match incrates/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 ownDefinitionwithkind: 'enum'from the same node'sname/line.collectExportedDeclarationsand Rust'shandle_export_declarationare 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
tests/parsers/javascript.test.ts(TS/WASM path) andcrates/codegraph-core/src/extractors/javascript.rs(native path): an exported enum produces both aDefinition(kindenum) and anExport(kindenum) at the correct line; a non-exported enum still gets aDefinitionbut noExport.codegraph build --engine wasmand--engine native(rebuilding the native addon from this branch's Rust source) —codegraph exportscorrectly lists the exported enum and correctly omits the non-exported one, for both engines.cargo fmt -- --checkandcargo test --lib extractors::javascript(328/328) clean.npm run lintclean.npx vitest run: 5534/5534 tests pass (344 test files, +2 new).