Skip to content

TypeScript improvements #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dsebastien opened this issue Jul 6, 2021 · 4 comments
Closed

TypeScript improvements #1

dsebastien opened this issue Jul 6, 2021 · 4 comments

Comments

@dsebastien
Copy link
Contributor

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

sim51 commented Jul 6, 2021

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

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

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

@sim51
Copy link
Owner

sim51 commented Jul 12, 2021

Thanks a lot !
TS is much better now :)

@sim51 sim51 closed this as completed Jul 12, 2021
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

No branches or pull requests

2 participants