简体   繁体   中英

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?

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 for your typescript transpiler can access it

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM