Environment
- graphify 0.9.49 (PyPI
graphifyy), Linux, Python 3.12
graphify.extract.extract([...])
Summary
TypeScript enum members are not extracted as nodes. enum_declaration is in _TS_CONFIG.class_types and the comment there reads # parity with Java/C#, but only the container half of that parity is implemented: the enum type gets a node, its members do not, and the type sits in the graph as a leaf.
This is the same gap #1700 reported for Kotlin/Java, fixed for Java in #1719 and Kotlin in #1738. Swift emits case_of for enum_entry, and PowerShell enum members landed in 0.9.49 via #3002.
Reproducer
// color.ts
export enum Direction {
Up = "UP",
Down = "DOWN"
}
Current behavior (0.9.49)
color_ts color.ts
color_direction Direction (no children)
Up and Down are not in the node table, and Direction has no outgoing edges. String enums like this are the common TS spelling, so the members carry the meaning and the type name alone carries very little.
Expected
The Java shape:
color_direction --case_of--> color_direction_up
color_direction --case_of--> color_direction_down
Grammar notes
The walk already reaches the members: enum_declaration's body field resolves to enum_body, and the class handler descends into its children with the enum as parent_class_nid. There is no handler for the member node types.
TS spells a member two ways, and both need covering:
- a bare
Red is a property_identifier
Green = 5 is an enum_assignment whose name field is a property_identifier, or a string when the member is quoted ("Odd Name" = 7), where the label wants the string_fragment rather than the quoted literal
property_identifier also appears all over a normal TS file, so a handler has to be scoped to nodes whose parent is enum_body rather than matching the type alone.
One more wrinkle shared with C#: TS is case-sensitive while normalize_id casefolds, so enum E { Value, value } puts two legal members on one id.
I have a patch and will open it against this.
Environment
graphifyy), Linux, Python 3.12graphify.extract.extract([...])Summary
TypeScript enum members are not extracted as nodes.
enum_declarationis in_TS_CONFIG.class_typesand the comment there reads# parity with Java/C#, but only the container half of that parity is implemented: the enum type gets a node, its members do not, and the type sits in the graph as a leaf.This is the same gap #1700 reported for Kotlin/Java, fixed for Java in #1719 and Kotlin in #1738. Swift emits
case_offorenum_entry, and PowerShell enum members landed in 0.9.49 via #3002.Reproducer
Current behavior (0.9.49)
UpandDownare not in the node table, andDirectionhas no outgoing edges. String enums like this are the common TS spelling, so the members carry the meaning and the type name alone carries very little.Expected
The Java shape:
Grammar notes
The walk already reaches the members:
enum_declaration'sbodyfield resolves toenum_body, and the class handler descends into its children with the enum asparent_class_nid. There is no handler for the member node types.TS spells a member two ways, and both need covering:
Redis aproperty_identifierGreen = 5is anenum_assignmentwhosenamefield is aproperty_identifier, or astringwhen the member is quoted ("Odd Name" = 7), where the label wants thestring_fragmentrather than the quoted literalproperty_identifieralso appears all over a normal TS file, so a handler has to be scoped to nodes whose parent isenum_bodyrather than matching the type alone.One more wrinkle shared with C#: TS is case-sensitive while
normalize_idcasefolds, soenum E { Value, value }puts two legal members on one id.I have a patch and will open it against this.