Plugins have no types
exoRift opened this issue ยท 10 comments
Something goes wrong with Rollup when building as the plugins lose their typing (and recognition as importable modules) causing them to need manual declaration like so
declare module 'cal-heatmap/plugins/CalendarLabel'
declare module 'cal-heatmap/plugins/Tooltip'
declare module 'cal-heatmap/plugins/LegendLite'
However, this, of course, does not come with the typings the plugins should have
I'm trying to use the the lib and it's plugins in an Angular 16 App, so far I had success with the main lib but can't import the plugins.
import LegendLite from 'cal-heatmap/plugins/LegendLite';
gives error TS2307: Cannot find module 'cal-heatmap/plugins/LegendLite' or its corresponding type declarations.
tried
declare module 'cal-heatmap/plugins/LegendLite';
but it gives error TS2664: Invalid module name in augmentation, module 'cal-heatmap/plugins/LegendLite' cannot be found.
Yeah, to remedy this, I forked the branch and wrote a custom build script without Rollup and have just been using that in my project directly.
Hi @exoRift it seems your fork isn't public, would you mind sending a pull request or sharing the repo?
@htrex It's under my organization.
https://github.com/guidance-analytics/cal-heatmap
It can be installed with npm i "github:guidance-analytics/cal-heatmap#ga-override-v2"
(#ga-override-v2
specifies the tag to make sure it doesn't change, or you can fork it yourself. Whichever you decide)
thanks @exoRift It works as a temporary solution, even if it gives Uncaught SyntaxError: Cannot use import statement outside a module
Yeah, I'm emitting ES code. You can either fork and change the emit, or use type: module
in your package json since you're using TS anyway
after some more experiments with cal-heatmap in an angular 16 app it seems that @exoRift first comment is the way to go, I was missing that the declare module
statements must be in src/index.d.ts
I'm trying to use the the lib and it's plugins in an Angular 16 App, so far I had success with the main lib but can't import the plugins.
import LegendLite from 'cal-heatmap/plugins/LegendLite';
gives error TS2307: Cannot find module 'cal-heatmap/plugins/LegendLite' or its corresponding type declarations.
I encountered the same issue while using React 17 + NextJS 12. I tried adding the following declarations in src/index.d.ts
:
declare module 'cal-heatmap/plugins/CalendarLabel';
declare module 'cal-heatmap/plugins/Tooltip';
declare module 'cal-heatmap/plugins/LegendLite';
However, the error persists ๐ฅ. Did I miss anything?"
Same with angular 17
Should be fixed in master, will do some more test before releasing