-
Notifications
You must be signed in to change notification settings - Fork 715
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
Conversation
…dep, specify types in package.json
|
||
export default function DefaultLink({ link }) { | ||
return ( | ||
export default function DefaultLink({ link }: LinkProvidedProps<any>) { |
There was a problem hiding this comment.
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>>
?
There was a problem hiding this comment.
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 👎
There was a problem hiding this 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, |
There was a problem hiding this comment.
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}) => ...
There was a problem hiding this comment.
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)
🚀 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
React.Fragment
s, which requires bumping thepeerDep
forreact
to^16.3.0-0
<Nodes />
<g>
elementclassName
changed to singular (vx-network-nodes
=>vx-network-node
)<g>
was replaced with aReact.Fragment
<Links />
<g>
elementclassName
changed to singular (vx-network-links
=>vx-network-link
)<g>
was replaced with aReact.Fragment
Tests
/network
demo@hshoff @schillerk @milesj @kristw @Rudeg