Ports property in a node is not working

new go.Binding("ports", "data", (val) => {
        let portArr: go.List<go.GraphObject> = new go.List();
        let tempPid = 0
        for (let port of val.cases) {
          tempPid = port.portIndex
          portArr.add(makePort("out", tempPid.toString(), go.Spot.Left))
        }
        portArr.add(makePort("out", (tempPid + 1).toString(), go.Spot.Left))
        console.log("ports", portArr.iterator)
        return portArr.iterator;
      }),

and my makePort() method is

const makePort = (name: string, pid: string, spot: go.Spot): go.GraphObject => {
    return $(go.Shape, "Circle",
      {
        name: name,
        portId: pid,
        fromLinkable: name !== "in",
        toLinkable: name === "in",
        alignment: spot,
        fromSpot: spot,
        toSpot: spot,
        stroke: name === "exception" ? "red" : "black",
        fill: "#dddddd",
        desiredSize: new go.Size(6, 6),
        cursor: "pointer",
        strokeWidth: 1.5,
        opacity: 0
      })

  }

But there is no visible ports and for even single ports also it doesn’t work

 {
      port: makePort("in", " ", go.Spot.Top)
    },

Node | GoJS API is a read-only property, so trying to use that property as the target of a Binding cannot work.

More generally, one cannot use a Binding to change the structure of the Part’s visual tree. It can only be used for automatically transferring property values from the source property to the target property. (Or also the opposite when the Binding is TwoWay.)

There are many examples where the number of ports is determined by a node data property that is an Array of port description objects.

new go.Binding("itemArray", "cases"),

And your Panel.itemTemplate would be or include a port element, where there would be a Binding of GraphObject.portId.

I want to add no of ports in a side of iterative manner,I tried itemArray but it is for only a panel,I need to add iterative shapes

ItemArrays are the only way to have a varying number of elements in a panel controlled by an Array in the data.
https://gojs.net/latest/intro/itemArrays.html