I am using GoJS 1.6.13 and I see your example with Electron.
go = require(“gojs”); // assumes: $ npm install gojs
My IDE is VS code, which has a really strong support on intellisense. It complains that gojs is not a module. I then go to go.d.ts to see the definition, the module is defined as “go” instead of “gojs”. When I change this line to go = require(“go”), my compiler is happy but I cannot launch it through Electron. But if I just double-click on html, it still works.
Uncaught ReferenceError: go is not defined
Do you have any idea? This is currently blocking my work.
In version 1.6.3, we had not yet renamed the TypeScript definition file to be “go.d.ts”. If you have recently done an “npm install gojs” or “npm update”, you would not be using version 1.6.3 any more.
I think I “hacked” it out. What is the wrong on using ‘go’ as filename, namespace and module name? Using ‘gojs’ resolves all issues.
I have to do three things in order to make typings/intellisense and runtime work at the same time.
rename go.d.ts to gojs.d.ts
modify the namespace ‘go’ in gojs.d.ts to ‘gojs’ and update the last line of export module to gojs
declare module “gojs” { // comment out module declaration for TypeScript 2.0
export = gojs; // but keep export = go in all versions for compatibility with AMD and CommonJS
}
I struggled all day trying to get gojs intellisense working in VS code. (It had previously been working, and intellisense for other modules was working).
This process appeared to work:
Delete the directory C:\Users[yourname]\AppData\Roaming\npm-cache\gojs
Delete the directory C:\Users[yourname][Your project path]\node_modules\gojs
Delete the gojs entry in the package.json file.
Run npm install gojs --save
4.1. This results in the latest version of gojs being installed.
4.2. The –save results in the package.json file being updated.
I’m not sure all the steps were needed, and I had to start/restart VS code a couple of times. Still the “secret” is buried somewhere in the steps above.