Closed fibo closed 1 year ago
@fibo forgive my big lack of knowledge in TS. I'm curious why you need to import the adapter. Do you need to use the DateAdapter methods outside of Chart.js?
I have a Chart.tsx component that uses chart.js lib,
When I import it with
import "chartjs-adapter-luxon";
I have this warning
I can create a PR to solve this warning if you think it is worth.
Thank you very much. As said, I'm not really an expert on TS and I'm sure I'm missing something and therefore I don't know if it's worth or not.
I was curious how could work and needs (having done some tests in a my branch, creating the index.d.ts).
yes if you add a dist/index.d.ts file and reference it in you package.json, it should be enough
"types": "./dist/index.d.ts"
yes, did. But I am interested to understand what to export. The module creation sounds "simple" but I am also thinking about the luxon options (see readme) that are not defined anywhere and could be in chartjs config (in scale.adapters.date).
Nothing gets exported or is configurable for the adapter, I also dont get any TS errors while trying to reproduce it. https://codesandbox.io/s/react-typescript-forked-5s45fs?file=/src/App.tsx
Adding an empty declaration sounds kind of hacky to me not sure if it will solve the issue since apperently your compiler sees something being exported being typed as any and adding an empty declaration file wont solve that since it will still be any in that case
Importing chartjs-adapter-luxon in a TypeScript module you get a complain about missing typings declaration.
I solved adding an chartjs-adapter.luxon.d.ts file with content
I do not know if it is the right solution, but for sure including an index.d.ts file in this package would save time to many other developers, in particular those that are starting with TypeScript.