Error after updating gojs


#1

i was previously using older go js api i just updated and it gave me errors
findTreeParetLink doesnot exists on part


and another one


#2

and another one


#3

The TypeScript compiler is telling you that you need to either check at runtime that the value is a Node, or that you should declare that it is a Node using a cast.

As the compiler is getting better and as TypeScript definitions files are getting better, the compiler is catching more potential bugs. We definitely improved our go.d.ts file a lot for version 2.0, partly due to our reimplementation of the GoJS library in TypeScript.


#4

what about the shape when i cast it to shape it tells me i have 37 missing arguments


#5



#6

same for the selnode


#7

???
I suggest that you fix your code as much as you can. Then if there are any errors left, you can ask again. Please show the whole code – your screenshots above hide important parts of your code. Show the error message text separately.


#8

first error is on var shape : go.shape which is

second error is on the last ie var selnode :go.Node which is


#9

https://gojs.net/latest/api/symbols/Panel.html#findObject clearly returns a GraphObject, not a Shape.

So you either need to cast it to be a go.Shape, or you need to check it at runtime by using if (shape instanceof go.Shape) {


#10

what about the node one the selnode?


#11

and can u tell me about these 2 too

its an error that .member part doesnot exist on type node but it works fine in js
Screenshot%20from%202019-05-13%2016-35-38

the second one is


addlinkdata doesnot exist on type model?
Screenshot%20from%202019-05-13%2016-36-14


#12

I think all of those cases are similar – code is assuming a value is of a narrower type than how it is declared.

I don’t understand how any of that code could have compiled, even back with GoJS version 1.4 when we first added a go.d.ts definitions file to support TypeScript. Did you just change the TypeScript configs?


#13

nop i didnt change any thing


#14

npm install gojs and good to go


#15

can u help me with the last 2 the addlinkdata doesnot exist on type model? and
.member part doesnot exist on type node


#16

If you search for those properties or methods at https://gojs.net/latest/api/ you will find the class that they belong to. Thus you will know how to compile-time cast or run-time check.

When you have opened https://gojs.net/latest/api/, you can just start typing the name you are searching for.