Hello,
I am trying to integrate CanvasJS into Angular 8 app, and it gives compile error as shown below.
PS C:\dev\projects\ngx1> ng serve
NOTICE: Hot Module Replacement (HMR) is enabled for the dev server.
10% building 3/3 modules 0 activei 「wds」: Project is running at http://localhost:4200/webpack-dev-server/
i 「wds」: webpack output is served from /
i 「wds」: 404s will fallback to //index.html
chunk {main} main.js, main.js.map (main) 2.13 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 122 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 31.1 kB [entry] [rendered]
chunk {scripts} scripts.js, scripts.js.map (scripts) 1.01 MB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 702 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 342 kB [initial] [rendered]
Date: 2019-09-23T16:30:30.775Z - Hash: c37aaa7e5a59509af3c5 - Time: 12546ms
ERROR in src/app/components/trends/trends.component.ts:2:27 - error TS7016: Could not find a declaration file for module './canvasjs.min'. 'C:/dev/projects/ngx1/src/app/components/trends/canvasjs.min.js' implicitly has an
'any' type.
2 import * as CanvasJS from './canvasjs.min';
~~~~~~~~~~~~~~~~
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
i 「wdm」: Failed to compile.
I have copied canvasjs.min.js into the same folder as my angular component and am importing it using:
import * as CanvasJS from './canvasjs.min';
I have tried creating a typings file canvasjs.min.d.ts in the same folder as my angular component, with the following declaration.
declare module 'canvasjs.min';
When I do this, I get a new compile error:
ERROR in src/app/components/trends/trends.component.ts(2,27): error TS2306: File 'C:/dev/projects/ngx1/src/app/components/trends/canvasjs.min.d.ts' is not a module.
I have downloaded your Angular 5 sample and can compile and run it without error. Is there some way to get this to work in Angular 8?
Thank You