sim51 / react-sigma

Sigma React component
https://sim51.github.io/react-sigma/
Other
158 stars 27 forks source link

TypeScript improvements #1

Closed dsebastien closed 2 years ago

dsebastien commented 3 years ago

Hello there!

I'm interested in contributing a few TypeScript improvements to this project, as I plan on using it for a PoC.

I have already forked the project and made some changes for better type safety: https://github.com/dsebastien/react-sigma-v2/commits/main

One thing that is not clear for me is this: https://github.com/sim51/react-sigma-v2/blob/main/src/index.ts#L21

Can you tell me what NodeKey is supposed to be? It's not defined at the moment it seems. For now I've tried using import { NodeKey } from "graphology-types";, which is in fact string | number, but then I get errors in the complete.tsx example, where the code always expects the hoveredNode state to be a string.

sim51 commented 3 years ago

It's weird, the project compiles without warning, but it's true that NodeKey is not defined in the index.ts ... I need to check that. Tthe hover node in the example should be const [hoveredNode, setHoveredNode] = useState<NodeKey | null>(null);

And fill free to make a PR with your improvments !

dsebastien commented 3 years ago

It's because the TS configuration is very lenient atm (check my commits to see how I've made it stricter). I'll send a PR later today

dsebastien commented 3 years ago

I've adapted the examples based on what you told me. They still seem to work fine ;-)

sim51 commented 2 years ago

Thanks a lot ! TS is much better now :)