Skip to content

refactor: Added TypeScript Type Definitions#24

Open
Aarebecca wants to merge 2 commits intovasturiano:masterfrom
Aarebecca:chore/types-definition
Open

refactor: Added TypeScript Type Definitions#24
Aarebecca wants to merge 2 commits intovasturiano:masterfrom
Aarebecca:chore/types-definition

Conversation

@Aarebecca
Copy link

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.

@Aarebecca Aarebecca mentioned this pull request Apr 8, 2024
@Aarebecca Aarebecca force-pushed the chore/types-definition branch from 0de7ac5 to 30ed163 Compare April 8, 2024 09:26
@Aarebecca Aarebecca force-pushed the chore/types-definition branch from 30ed163 to a5df879 Compare April 8, 2024 12:29
@vasturiano
Copy link
Owner

@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
Copy link
Author

Aarebecca commented Apr 9, 2024

@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
Copy link

@vasturiano any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants