[2.0.0-beta11] Cannot read property 'classType' of undefined


#1

I have changed from 2.0.0-beta5 to beta11 and now getting the stacktrace below. Any ideas on what has changed from beta5 to beta11 that could cause this and changes I need to make?

Uncaught TypeError: Cannot read property 'classType' of undefined
    at Ab (go-debug.js:355)
    at Lh.set (go-debug.js:29001)
    at Ej (go-debug.js:14788)
    at Jl (go-debug.js:20485)
    at Hl (go-debug.js:20449)
    at buildBaseTemplate (roundNodes.js:83)
    ...
  352 | }
  353 | 
  354 | function Ab(a, b, c, d) {
> 355 |   a.classType !== b && (c = za(c), void 0 !== d && (c += "." + d), Aa(a, "function" === "a constant of class " + typeof b.className ? b.className : "", c));
      | ^  356 | }
  357 | 
  358 | na.Object.defineProperties(D.prototype, {

Here is our code that is building the template with the stacktrace code marked with a comment.

const buildBaseTemplate = ({
  fromLinkable = true,
  toLinkable = true,
  fromLinkableSelfNode = true,
  toLinkableSelfNode = true
}) => {
  const { make } = go.GraphObject;

  return make(
    go.Node,
    'Table',
    { resizable: true },
    new go.Binding('location', 'location').makeTwoWay(),
    new go.Binding('width', 'width').makeTwoWay(),
    new go.Binding('height', 'height').makeTwoWay(),
    new go.Binding('visible', 'nodeVisible'),
    make(
      go.Panel,
      'Table',
      { row: 0, column: 0, alignment: go.Spot.Top, stretch: go.GraphObject.Fill },
      make(
        go.Panel,
        'Auto',
        { row: 0 },
        make(
          go.Shape,
          'Circle',
          {
            name: 'LinkHandle',
            portId: '',
            height: cfg.circleSize,
            width: cfg.circleSize,
            fromLinkable,
            toLinkable,
            fromLinkableSelfNode,
            toLinkableSelfNode,
            strokeWidth: 0,
            fill: 'transparent',
            cursor: 'pointer',
            mouseOver: mouseOverNode,
            mouseLeave: mouseLeaveNode
          },
          new go.Binding('fill', 'stateColor')
        ),
        make(
          go.Shape,
          'Circle',
          { height: cfg.circleSize - 20, width: cfg.circleSize - 20, strokeWidth: 0 },
          new go.Binding('fill', 'stateColor')
        ),
        make(  // <-- This is where stacktrace shows error
          go.Panel,
          'Vertical',
          { cursor: 'move' },
          make('Shape', { stroke: null, fill: '#fff' }, new go.Binding('geometry', 'iconSource'))
        )
      ),
      make(
        go.TextBlock,
        {
          row: 1,
          stretch: go.GraphObject.Fill,
          overflow: go.TextBlock.OverflowEllipsis,
          name: 'name',
          textAlign: 'center',
          editable: false,
          font: cfg.baseNodeFont,
          minSize: new go.Size(15, NaN),
          maxSize: new go.Size(76, NaN),
          cursor: 'text',
          margin: cfg.textMargin,
          stroke: cfg.textColor
        },
        new go.Binding('text', 'text').makeTwoWay()
      )
    ),

    // Badge
    make(
      'Panel',
      'Auto',
      { row: 0, column: 0, alignment: go.Spot.TopRight, margin: new go.Margin(0, 15, 0, 0), visible: false },
      new go.Binding('visible', 'badgeVisible'),
      make('Shape', 'Badge', { strokeWidth: 0, fill: '#ff3b30' }),
      make(
        'TextBlock',
        { textAlign: 'center', font: cfg.baseBadgeFont, stroke: '#fff' },
        new go.Binding('text', 'badgeText')
      )
    ),

    // Overlay
    make(
      'Panel',
      // 'Auto',
      { row: 0, column: 0, alignment: go.Spot.TopRight, margin: new go.Margin(40, 0, 0, 0) },
      new go.Binding('visible', 'overlayVisible'),
      make(
        'TextBlock',
        {
          textAlign: 'center',
          font: `${cfg.overlaySize}px workpoint`, // Need to implement this with SVG
          width: cfg.overlaySize + 2,
          height: cfg.overlaySize + 2
        },
        new go.Binding('text', 'overlayText'),
        new go.Binding('stroke', 'overlayStroke')
      )
    )
  );
};
    this.diagram = go.GraphObject.make(go.Diagram, id, {
      nodeTemplateMap: getNodeTemplateMap(theme), // <-- HERE
      linkTemplateMap: getLinkTemplateMap(theme),
      initialPosition: new go.Point(0, 0),
      isReadOnly: false,
      'undoManager.isEnabled': true,
      allowClipboard: true,
      'animationManager.isEnabled': false,
      'toolManager.mouseWheelBehavior': go.ToolManager.WheelZoom,
      'grid.visible': !!settings.showGrid,
      'grid.gridCellSize': new go.Size(gridSize, gridSize),
      'resizingTool.isGridSnapEnabled': !!settings.gridSnapOnMove,
      'draggingTool.isGridSnapEnabled': !!settings.gridSnapOnMove,
      'draggingTool.gridSnapCellSize': new go.Size(gridSnapSize, gridSnapSize),
      model
    });

#2

Thanks, we’ll look into this.

Does using just go.js still work for you? Or are they both (go.js and go-debug.js) broken? It may just be a bug in the checking itself.


#3

Looks like go.js is fine.


#4

I forked a sandbox from beta 5 moving to beta 11 and it doesn’t like this import. Has it changed from beta 5 to 11?

import * as go from 'gojs/release/go-debug';

Here is the sandbox I was trying to make work.

Edit GoJS 2 classType error


#5

I’ve fixed the first issue you’ve found, but I’m not so sure on the second one. In that fork, if I downgrade the package to beta5, I get a different error in the sandbox. Is that what you get?

Locally, if I make a TypeScript file and use

import * as go from '../release/go-debug';

Like in the extensionsTS directory, and run tsc with 3.2.1, there seems to be no issue, so I’m not sure what’s going on in this project.


#6

Yes I can’t get my GoJS sandboxes running the B5 or B11 right now. I even have others that used to run but aren’t now.

Anyway if you fixed the issue with go-debug then I won’t waste any more time trying to get a sandbox to work that demos it!


#7

Ok. Does your local react setup still work fine with B5 or the latest Beta and not show this error? If so I won’t wrory about it, but if there’s some problem with React I’d like to look into it.

If it helps, I can give you a working go-debug.js (with the bugfix), what will eventually become Beta 12.


#8

Yes my local React project is working just fine with B5. I’m using NPM so if you think B12 will be pushed there in a week or so I can just wait for that.


#9

Yeah, within a week probably.


#10

@simon Just checking in to see if B12 is close? I would really like to get off B5 but this issue is blocking me.


#11

I can’t guarantee it, but we will probably release tomorrow.


#12

@estesbubba We’ve just released Beta 12, you should be able to get it on npm with the beta tag. Let me know if there are any other issues.


#13

I updated to B12 and no longer see this stacktrace.