NorthwoodsSoftware / GoJS

JavaScript diagramming library for interactive flowcharts, org charts, design tools, planning tools, visual languages.
http://gojs.net
Other
7.7k stars 2.86k forks source link

CustomLink not working #157

Closed amrit981 closed 3 years ago

amrit981 commented 3 years ago

I am converting dynamic node code to react js. I need to create a custom link for that. I ah getting two errors

  1. myDiagram.linkTemplate = $(CustomLink, // defined below { routing: go.Link.AvoidsNodes, corner: 4, curve: go.Link.JumpGap, reshapable: true, resegmentable: true, relinkableFrom: true, relinkableTo: true }, new go.Binding("points").makeTwoWay(), $(go.Shape, { stroke: "#2F4F4F", strokeWidth: 2 }) );

I this code "CustomLink" says this error

Error: No overload matches this call. The last overload gave the following error. Argument of type '() => any' is not assignable to parameter of type 'ConstructorType<() => any>'. Type '() => any' provides no match for the signature 'new (...args: any[]): any'.

  1. function CustomLink():any{ go.Link.call(this); } In this code I am getting the error written below

Error: 'this' implicitly has type 'any' because it does not have a type annotation.ts

Because of these tow issues I can't move further. Someone suggested to create a separate class for Link. But I am not able to do it. Will any one has any example for that

CustomLink as a proper class in ES6, class CustomLink extends go.Link { } --- > Like this

WalterNorthwoods commented 3 years ago

This is not an issue/bug/problem with the GoJS library or its documentation, so you should not be using GitHub Issues.

The use of function name() { ... } followed by go.Diagram.inherit(...) is old class-defining syntax that works in all browsers. You can find examples of custom classes using the newer class syntax in the extensionsJSM and extensionsTS subdirectories as well as in https://gojs.net/latest/intro/extensions.html#OverridingMethodsBySubclassingLayout