Home Forums Chart Support Typescript TS7016: Could not find a declaration file for module ‘./canvasjs.min’

Typescript TS7016: Could not find a declaration file for module ‘./canvasjs.min’

Viewing 4 posts - 1 through 4 (of 4 total)
  • #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,

    CanvasJS Chart supports all versions of angular and chart seems to be working fine in Angular 8. Please take a look at this Sample project for a working example on creating column chart in Angular 8.

    Column chart in Angular 8

    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

    #34418
    #34452

    @josefinanoya,

    Glad that you figured it out. Adding "noImplicitAny": false, inside the compilerOptions in TypeScript Config file(tsconfig.json) seems to be working fine.

    —-
    Manoj Mohan
    Team CanvasJS

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

You must be logged in to reply to this topic.