Fix TypeScript definitions for missing force graph methods #715
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.
Problem Summary
Issue: Property 'graphData' does not exist on type 'ForceGraph3D<NodeObject, any>'
Impact: Critical - Blocks all TypeScript users from upgrading to v1.74.0+
Root Cause: Missing method definitions in TypeScript interface
Technical Analysis
The issue was caused by incomplete TypeScript definitions in
src/index.d.ts. While the interface extendedThreeForceGraphGeneric(which provides methods likegraphData,warmupTicks, etc.), some methods from the JavaScript implementation'slinkedFGMethodswere not properly exposed in the TypeScript definitions.Missing Methods Identified
From
linkedFGMethodsinsrc/3d-force-graph.js:refresh()- Redraws all nodes/linksgetGraphBbox()- Returns graph bounding boxd3Force()- Getter/setter for d3 simulation forcesd3ReheatSimulation()- Reheats the force simulationemitParticle()- Emits particles on demandSolution Implemented
1. Updated TypeScript Interface
Added explicit method definitions to
ForceGraph3DGenericInstanceinterface insrc/index.d.ts:2. Verified Fix
yarn buildcompleted successfullyTesting Performed
TypeScript Compilation Test
✅ Result: Compiles without TypeScript errors
Method Availability Test
graphData()- Core method now properly typedwarmupTicks()- Available through base class extensionrefresh()- Now explicitly definedgetGraphBbox()- Now explicitly definedImpact
Before Fix
After Fix
Deployment Notes
Fix #694