Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugins have no types #366

Open
exoRift opened this issue Jun 15, 2023 · 10 comments
Open

Plugins have no types #366

exoRift opened this issue Jun 15, 2023 · 10 comments
Assignees

Comments

@exoRift
Copy link

exoRift commented Jun 15, 2023

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

@htrex
Copy link

htrex commented Jul 6, 2023

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.

@exoRift
Copy link
Author

exoRift commented Jul 6, 2023

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.

@htrex
Copy link

htrex commented Jul 7, 2023

Hi @exoRift it seems your fork isn't public, would you mind sending a pull request or sharing the repo?

@exoRift
Copy link
Author

exoRift commented Jul 7, 2023

@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)

@htrex
Copy link

htrex commented Jul 10, 2023

thanks @exoRift It works as a temporary solution, even if it gives Uncaught SyntaxError: Cannot use import statement outside a module

@exoRift
Copy link
Author

exoRift commented Jul 10, 2023

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

@htrex
Copy link

htrex commented Jul 14, 2023

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

@Kim716
Copy link

Kim716 commented Nov 29, 2023

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?"

@ghost
Copy link

ghost commented Dec 30, 2023

Same with angular 17

@wa0x6e
Copy link
Owner

wa0x6e commented Jan 21, 2024

Should be fixed in master, will do some more test before releasing

@wa0x6e wa0x6e self-assigned this Jan 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants