Search code examples
typescripttypescript-typingsdc.js

dc.js types in typescript


I have a problem with types when I use dc.js version 4.2.7. In order to solve it I installed what seems to be the default types module for dc.js with the following command:

Install command I used

npm i @types/dc

My code works correctly in javascript. However in typescript I either struggle with the types or when I use @types/dc it won't let me import the chart classes.

It seems to me that the types module is outdated because even though it doesn't lets me import the chart classes it does let me import the old function based API that dc.js used in older versions.

How can I solve this issue?


Solution

  • After doing some search I found that what the user Gordon in the comment above was saying is indeed true. @types/dc for dc v4 is outdated and it won't work correctly.

    A quick, dirty way of at least handling the types warnings would be to simply declare the module like so:

    dc.d.ts

    declare module "dc";
    

    Some where accessible where your typescript transpiler can access it