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

Getting issues in GuidedDraggingTool.ts #191

Closed harshittpandey closed 1 year ago

harshittpandey commented 1 year ago

My gojs version: "^1.8.37" I am importing the gojs extensions like this.

import {GuidedDraggingTool} from 'gojs/extensionsTS/GuidedDraggingTool'
import {Robot} from 'gojs/extensionsTS/Robot'

but while running jest, I am getting some typescript issues I am transforming node_modules/gojs with ts-jest

node_modules/gojs/extensionsTS/GuidedDraggingTool.ts:176:7 - error TS2322: Type 'null' is not assignable to type 'GraphObject'.

176   var bestPart: go.GraphObject = null;
          ~~~~~~~~

node_modules/gojs/extensionsTS/GuidedDraggingTool.ts:206:59 - error TS2454: Variable 'bestOtherSpot' is used before being assigned.

206    var bestPoint = new go.Point().setRectSpot(bestBounds, bestOtherSpot);
                                                              ~~~~~~~~~~~~~

node_modules/gojs/extensionsTS/GuidedDraggingTool.ts:207:8 - error TS2454: Variable 'bestSpot' is used before being assigned.

207    if (bestSpot === go.Spot.Center) {
           ~~~~~~~~

total 19 errors in both the extensions that I am using.

I figured out a way to handle this, I tried importing the extensions from .js file.

import {GuidedDraggingTool} from 'gojs/extensionsTS/GuidedDraggingTool.js'
import {Robot} from 'gojs/extensionsTS/Robot.js'

with this, my unit tests are working fine.

but I am still getting the same typescript errors while running the build. and inside my tsconfig.json, I am excluding "node_modules" and using skipLibCheck: true.

I don't understand why these typescript checks are failing even if I am not directly importing/ using them. and I am excluding them from my tsconfig.json as well.

WalterNorthwoods commented 1 year ago

Follow our recommendations to copy extension files into your project so that they are compiled and imported correctly for your project.