Search code examples
powerbicreatejs

Using createJS in typescript?


I am attempting to incorporate createJS into a typescript project (a powerbi visual) that I am building.

I have done the following:

1) Installed createJS and typings file using:

npm install createjs --save and npm install --save @types/createjs

2) Added this line to the the externalJS array in pbiviz.json : "node_modules/createjs/builds/1.0.0/createjs.min.js"

3) Added the path to the typings file to the files array in my tsconfig.ts file: "node_modules/@types/createjs/index.d.ts".

Something didn't go right, I'm seeing the following error in my console: Error Trace

This was without actually calling the namespace in my code, if I attempt to use the namespace then it simply breaks my code without any warnings. My IDE's auto-suggest offers createjsimplying to me that it was imported properly but still something isn't right.

I think its related to this thread but I don't understand how to implement the solution it typescript. Can anyone help?

My project structure: structure


Solution

  • It appears that the issue is an internal issue. I found a solution that I will not pretend to fully understand.

    Starting from scratch, instead of installing the createjs package with the --save option I ran

    npm install createjs-module --save and npm install --save @types/createjs

    which is apparently a webpack.

    After this I "node_modules/createjs-module/createjs.js" in to my externalJS array, as well as the appropriate typings file to my tsconfig.json.

    Credit to tsveti_iko

    see also:

    this