Giter Site home page Giter Site logo

Comments (7)

WalterNorthwoods avatar WalterNorthwoods commented on May 1, 2024

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?

from gojs.

herecydev avatar herecydev commented on May 1, 2024

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.

from gojs.

WalterNorthwoods avatar WalterNorthwoods commented on May 1, 2024

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

    ---Walter

On Sep 13, 2016 05:25, "Dan Kirkham" [email protected] 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
.

from gojs.

herecydev avatar herecydev commented on May 1, 2024

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

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

from gojs.

WalterNorthwoods avatar WalterNorthwoods commented on May 1, 2024

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" [email protected] 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
.

from gojs.

herecydev avatar herecydev commented on May 1, 2024

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

from gojs.

WalterNorthwoods avatar WalterNorthwoods commented on May 1, 2024

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.

from gojs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.