Gojs Error in Typescript SPFX

Those error messages don’t make any sense at all. The go.d.ts file is generated by the TypeScript compiler when compiling the GoJS source code. We never see that kind of error in our use of it, and no one else has reported anything like it.

The “How to fix …” link would be useful for someone who knew where the problem was occurring, but I have no idea about that. I don’t understand why getting the latest version of software from npm would result in a broken process – I think waiting until the responsible people fix it correctly is my only practical choice for now.

this error was not occuring when Iam using lower version of typescript

Could you please show the TypeScript code that is being compiled that is causing the problem? Along with how you are invoking the compiler (tsc)?

I want to be able to reproduce the problem. Involving all kinds of other tools shouldn’t be necessary for reproducing a simple compilation bug.

You mean the go.d.ts file ?

only when u lower your node version as mentioned above you will be able to reproduce the problem

https://nodejs.org/download/release/v8.9.4/

The go.d.ts file is a TypeScript definitions file that we provide along with the go.js library. They are both in the release directory.

For code that is importing go-module.js, I believe the TypeScript compiler will use the go-module.d.ts file. But it’s the same file as go.d.ts.

In either case the definitions file is being used by the TypeScript compiler when compiling TS files that import the GoJS library. And as you can demonstrate for yourself, there is no problem compiling the TS files in the extensionsJSM directory.

do u have any workaround for this ?

If i install lower version of gojs it works but while doing gulp serve its giving me "Unanonymous AMD define error "
Similar issue has been reported in

u will able to reproduce the issue if you install the lower version of node js and then restart your system . then follow the all the procedures as i meantioned abve

You say that “it works” when you install a lower version of GoJS. Which version was that? But you are not saying that it works because clearly the “gulp serve” command fails. Are you saying merely that one gets beyond some exception? Which exception is that?

That other post in this forum didn’t seem to involve GoJS at all, according to the error message.

I cannot spend my time trying to debug SPFX development when the bugs clearly do not involve GoJS. I believe you and I should be spending time trying to find bugs that do involve GoJS. That’s why I asked for the TypeScript code that is causing tsc errors. Not the go.d.ts file, which is clearly OK.

The SPFX webpart was working fine before we have imported the gojs library . The version that doesnt cause any exception was “1.8” .
Regarding the previous post the error occured only after we are importing the gojs library into the picture.

We wouldnt have raised the issue here if its not for gojs. As you can clearly see in the screenshot something was throwing error in the go.d.ts file ’

Ah, that’s good to know. In doing this upgrade, I’m surprised that you are switching to using ES6 modules from UMD modules. Was that intended? If not, you should not be using go-module.js.

I have very less knowledge about UMD modules. But this is what my tsconfig looks like

Yes, you should not be using go-module.js. Since that was new for GoJS version 2.0, you couldn’t have been depending on it when using GoJS version 1.8. Go back to using the go.js library, any version.

yes i lower version there were no problem in running gulp serve but while adding the webpart getting the below error .
i have used import * as go from ‘gojs’; . This is occurring only when i import gojs

What happens if you use require instead?

const go = require("gojs");

when i use const goObj = go.GraphObject.make;
its giving me Property ‘GraphObject’ does not exist on type ‘unknown’.

Are you talking about a compilation error? You’ll need to have the compiler use the go.d.ts definitions file, which I think it won’t know about if you call require.

but the error occurs when i call require

??? You just said:

when i use const goObj = go.GraphObject.make;
its giving me Property ‘GraphObject’ does not exist on type ‘unknown’.

I am guessing you are talking about a compilation error at the line:

const goObj = go.GraphObject.make;

A call to require would not result in the compilation error complaining about “GraphObject” not being defined on the “go” object.

But if it’s not a TypeScript compiler error, you should say so and be clear and precise in your descriptions.

So if it is a run-time error, I’m guessing that “go” is not defined, which would be because it could not find and load the GoJS library. You’ll need to figure out the configuration so that it will work. You say that it worked before – just go back to that and then upgrade the version of GoJS that you are using, without making any source code or other configuration changes. Normally require takes a path to the library file.