Home forums Using CanvasJS Typescript TS7016: Could not find a declaration file for module './canvasjs.min'

This topic contains 1 reply, has 2 voices, and was last updated by  Manoj Mohan 3 weeks, 4 days ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #26877

    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

    #26897

    @eclinecharge-analytics-com,

    Charts seems to be working fine with Angular 8, please take a look at this Sample project for the same.

    If you are still facing the issue, kindly share sample project reproducing the issue over Google-Drive or Onedrive so that we can run sample locally at our end, understand the scenario better and help you out.

    —-
    Manoj Mohan
    Team CanvasJS

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.