Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript compile error: "... node_modules/gojs/release/go.d.ts' is not a module" #26

Closed
KostyaDanovsky opened this issue Aug 3, 2016 · 7 comments
Labels
enhancement A request for a new feature in the library

Comments

@KostyaDanovsky
Copy link

KostyaDanovsky commented Aug 3, 2016

I use Typescript 1.8 but to fix this issue I need to change following lines in go.d.ts file:

declare module "go" {  
  export = go;         
}

to
export = go;

@WalterNorthwoods
Copy link
Contributor

WalterNorthwoods commented Aug 3, 2016

I'm using TypeScript 1.8.35, and when the go.d.ts file includes, at the end of the file:

// for TypeScript 1.*:
declare module "go" {  // comment out module declaration for TypeScript 2.0
  export = go;         // but keep export = go in all versions for compatibility with AMD and CommonJS
}

I do not get an error when compiling the following code:

    var $ = go.GraphObject.make;  // for conciseness in defining templates

    var myDiagram: go.Diagram =
        $(go.Diagram, "myDiagram",  // create a Diagram for the DIV HTML element
            {
                // position the graph in the middle of the diagram
                initialContentAlignment: go.Spot.Center
            });

And the code executes correctly too.
So could you explain why you think there should not be a "go" module declaration in the go.d.ts file?

Are you using modules, and if so, how?

@herecydev
Copy link

herecydev commented Sep 13, 2016

I'm seeing the same problem. The package.json looks fine, both main and typings are pointing to the correct files. The typescript compiler throws the following: error TS2306: File 'C:/snipped/node_modules/gojs/release/go.d.ts' is not a module. The fix suggested at the top does work. The problem I have with the whole thing is that this is not a sustainable practice. I can't comment this code out during CI deployment or on another developer's machine. Can you please take another look at this problem.

Typescript 1.8.10. GoJs 1.6.15. Node v4.4.7.

@WalterNorthwoods
Copy link
Contributor

Which fix "suggested at the top" are you talking about?

    ---Walter

On Sep 13, 2016 05:25, "Dan Kirkham" notifications@github.com wrote:

I'm seeing the same problem. The package.json looks fine, both main and
typings are pointing to the correct files. The typescript compiler throws
the following: error TS2306: File 'C:/snipped/node_modules/gojs/release/go.d.ts'
is not a module. The fix suggested at the top does work. The problem I
have with the whole thing is that this is not a sustainable practice. I
can't comment this code out during CI deployment or on another developer's
machine. Can you please take another look at this problem.

Typescript 1.8.10.
GoJs 1.6.15.
Node v4.4.7.

``


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
#26 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AKv8d1rHMUK6EI_ZFf_l_q0rLD_SCcMWks5qpmwfgaJpZM4Jbs5R
.

@herecydev
Copy link

I need to change following lines in go.d.ts file:

declare module "go" {
export = go;
}
to
export = go;

@WalterNorthwoods
Copy link
Contributor

WalterNorthwoods commented Sep 13, 2016

How are you importing GoJS in your TypeScript code?

Later today I can experiment how such a change would work in AMD
environments, although I thought it did not.

    ---Walter

On Sep 13, 2016 05:45, "Dan Kirkham" notifications@github.com wrote:

I need to change following lines in go.d.ts file:

declare module "go" {

export = go;

}
to
export = go;


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
#26 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AKv8d8U-ApQJXbHjMljAYofGkAHQhdvJks5qpnCogaJpZM4Jbs5R
.

@herecydev
Copy link

With ES6 syntax; import * as go from "gojs"

@WalterNorthwoods
Copy link
Contributor

OK, I still cannot reproduce that TSC error, and that error you quoted does not make sense anyway. And a lot of other TypeScript definition files wrap their export = blah with a declare module "blah" { }.

But it does seem to work without that module declaration, so I'll change it for 1.6.17.

@WalterNorthwoods WalterNorthwoods added the enhancement A request for a new feature in the library label Oct 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A request for a new feature in the library
Projects
None yet
Development

No branches or pull requests

3 participants