Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 337
jogarcia Avatar asked Sep 17 '26 00:09

jogarcia


1 Answers

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

like image 110
jogarcia Avatar answered Sep 18 '26 22:09

jogarcia



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!