Skip to content
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

typescript(vx-network): re-write package in TypeScript #515

Merged
merged 9 commits into from
Oct 9, 2019

Conversation

williaster
Copy link
Collaborator

@williaster williaster commented Sep 24, 2019

🚀 Enhancements

This PR builds off #488 which introduces Typescript build config, and re-writes the @vx/network package in TypeScript.

It also removes an unneeded d3-force dependency. Closes #513.

💥 Breaking Changes

  • This PR introduces React.Fragments, which requires bumping the peerDep for react to ^16.3.0-0
  • <Nodes />
    • inner node wrapper <g> element className changed to singular (vx-network-nodes => vx-network-node)
    • outer wrapper <g> was replaced with a React.Fragment
  • <Links />
    • inner link wrapper <g> element className changed to singular (vx-network-links => vx-network-link)
    • outer wrapper <g> was replaced with a React.Fragment

Tests

  • CI
  • functional /network demo

@hshoff @schillerk @milesj @kristw @Rudeg


export default function DefaultLink({ link }) {
return (
export default function DefaultLink({ link }: LinkProvidedProps<any>) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can it be LinkProvidedProps<Link<DefaultNode>>?

Copy link
Collaborator Author

@williaster williaster Sep 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this at first, but got TS errors in the Links component when setting linkComponent = DefautlLink along the lines of Link<DefaultNode> is not assignable to Link 😭

wasn't sure of a better solution than this 👎

Copy link

@Rudeg Rudeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good 👍

nodes = [],
nodeComponent = DefaultNode,
className,
x = (d: any) => (d && d.x) || 0,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

x = (d:any) => ... => (d?: {x: number}) => ...
y = (d:any) => ... => (d?: {y: number}) => ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is similar to the defaultLink above, where I get the error Type 'Node' is not assignable to type '{ y: number; }' (even if we default the Node type to { x, y }, it's not guaranteed)

@williaster williaster changed the base branch from chris--typescript to master October 4, 2019 20:45
@hshoff hshoff merged commit 419018e into master Oct 9, 2019
@hshoff hshoff deleted the chris--typescript-vx-network branch October 9, 2019 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Re-write @vx/network in TypeScript
4 participants