vasturiano / d3-force-3d

Force-directed graph layout in 1D, 2D or 3D using velocity Verlet integration.
https://observablehq.com/@vasturiano/multi-dimensional-d3-force-simulation
MIT License
373 stars 54 forks source link

refactor: Added TypeScript Type Definitions #24

Open Aarebecca opened 7 months ago

Aarebecca commented 7 months ago

I noticed that the project was missing the ts type definition, so I inferred the type based on the implementation. If you have any questions, please point them out.

vasturiano commented 7 months ago

@Aarebecca that's good, thanks for your effort here, and for opening the PR.

I do think it would be better to base the type definitions on the existing d3-force package more widely used types, from DefinitelyTyped: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/d3-force/v2/index.d.ts

This module is an extension of d3-force, so for consistency it would be better to base it on those types, and extend it with the relevant sections, namely adding the 3rd (z) dimension, plus the numDimensions method.

Aarebecca commented 7 months ago

@vasturiano thank you very much for your advice. It was really an oversight on my part. I've redefined the types based on d3-force, which reduces some of the duplication and ensures consistency.

The screenshot below is a type check performed by ts-server (in strict mode), and everything is fine:

image
sakgoyal commented 3 months ago

@vasturiano any update on this?