Repository navigation
Extract Graph.js helpers into typed modules - #1819
Merged
Merged
Conversation
Pulls the self-contained, non-stateful pieces of Graph.js out into their own files and converts them to TypeScript, as prep for eventually converting Graph.js itself: - loadGraphData.ts: the fetch-response parsing logic from getGraph(), now a pure function instead of a class method - util.ts: populateHybridRelatives, findRelationship, numCredits, transformPoint, and formatTransform, all already-pure helpers - requirementParser.ts: moved from js/util/util.ts into the graph component directory, since it's only ever used by graph code Graph.js drops from 1832 to about 1550 lines and keeps its existing behavior exactly; GenerateForm.js and the two existing unit tests for the extracted functions were updated for the new import paths. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Coverage Report for CI Build 40495193109Coverage decreased (-0.04%) to 60.339%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
Bool's test fixture used `id` instead of `id_`, which is why
GraphNodeJSON.id_ had to stay optional and callers needing it
(Node.tsx, util.ts, loadGraphData.ts) used a `& { id_: string }`
intersection as a workaround. Real bool node data always has `id_`
(Graph.js keys bool elements by `boolJSON.id_`), so fix the fixture
instead and make id_ required on the shared type, dropping the
intersections. Also more accurate: Bool spreads its JSON prop onto
the DOM, so the fixture now matches what's actually rendered
(id_="bool1" rather than a plain id attribute).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Proposed Changes
Pulls the self-contained, non-stateful pieces of
Graph.jsout into their own files and converts them to TypeScript, as prep for eventually convertingGraph.jsitself. No behavior changes.loadGraphData.ts— the fetch-response parsing logic fromgetGraph()util.ts—populateHybridRelatives,findRelationship,numCredits,transformPoint, andformatTransform(all pure functions already)requirementParser.ts— moved fromjs/util/util.tsinto the graph component directoryGraphNodeJSON.id_required instead of optional, which letsNode.tsx,util.ts, andloadGraphData.tsdrop their& { id_: string }workaroundutil.ts/loadGraphData.tsOne TypeScript wrinkle:
.flat(Infinity)on the recursivePrereqTreetype blew up the compiler ("type instantiation is excessively deep"), a known limitation with self-referential array types in.flat()'s typing. Worked around by casting throughunknown[]before flattening — no behavior change.Screenshots of your changes (if applicable)
Not applicable — no UI changes.
Type of Change
Checklist
Before opening your pull request:
Boolsnapshot).After opening your pull request:
Questions and Comments
None.
🤖 Generated with Claude Code