Addlinkdata does not exist on type model

Hi

when trying to add a link to the model, I get the error above.
addNodeData and others work perfectly, I only get the error for addlinkdata and addlinkdataCollection.
I work in Angular 4 if it matters.

thanks

addLinkData is only defined on GraphLinksModel. Are you using a TreeModel?

nope, I’m using a graphLinksModel.
maybe it’s related to typescript somehow?

It’s defined in go.d.ts:

    export class GraphLinksModel extends Model {
        . . .
        addLinkData(linkdata: Object): void;
        . . .
    }

I think you need to cast the model value as a GraphLinksModel.

as in this.diagram.model: go.GraphLinkModel?

the question is why addNodeModel does work and addLinkModel does not?

http://gojs.net/latest/intro/usingModels.html#KindsOfModels

We might add other kinds of models in the future.

the way I declare it is :
this.diagram.model = new go.GraphLinksModel(this.subjectArray, this,linkArray)

anything I need to add?

But in go.d.ts:

    export class Diagram { . . .
        model: Model;
    }

sorry, I don’t get what I need to change here?

You know, after all of this, you still haven’t posted what line caused the compilation error.

Something like (m as go.GraphLinksModel).addLinkData(x)

Sorry,
yes the line is:
this.diagram.model.addLinkData(link)

any ideas? I can upload the whole file or send it via email if it helps?

Did you ever try Walter’s suggestion of changing the line to (this.diagram.model as go.GraphLinksModel).addLinkData(link)?

missed it,
tried it now - works perfectly.
takes some time to get used to all this types in TS and where I have to use them…

thanks again for your support and patience