Open magnusart opened 2 years ago
I managed to hack around it with
const l = instance.d3Force('link')! as ForceFn2 & { distance: (link: LinkObject) => number }
l.distance(() => 50)
But that is very ugly. I had to redefine ForceFn as that was not exported. Any input welcome!
I've seen in issues that I should be able to use the following code
myGraph.d3Force('link').distance(link => /* your logic */)
.However when using typescript the type signature
ForceFn
does not contain distance. Also thed3-force-3d
project is not typed as far as I could see, so I can't use that as a base without adding my own types.The return type is
ForceFn | undefined
which is an interface that looks like this:What is the recommended way do this in Typescript?