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

Wrong TS type for plugins prop #734

Closed
burtek opened this issue Sep 21, 2021 · 8 comments · Fixed by #782
Closed

Wrong TS type for plugins prop #734

burtek opened this issue Sep 21, 2021 · 8 comments · Fixed by #782
Assignees

Comments

@burtek
Copy link

burtek commented Sep 21, 2021

plugins?: Chart.PluginServiceRegistrationOptions[];

Shouldn't plugins type be Chart.Plugin[] rather than PluginServiceRegistrationOptions? See TS types of chart.js:

https://github.com/chartjs/Chart.js/blob/8e68481ec4e29599660332f58967f439fb2ef17c/types/index.esm.d.ts#L3490-L3499

@El-bana
Copy link

El-bana commented Oct 12, 2021

Any workarounds found other than changing the node module file until this is fixed?

ok I used this to solve it temporarily

plugins={([plugin] as unknown as PluginOptionsByType<any>)}

@dangreen dangreen self-assigned this Oct 12, 2021
@burtek
Copy link
Author

burtek commented Oct 12, 2021

@El-bana I just went with as any for now, I still need to refactor that PoC part of my project ;p

@dangreen
Copy link
Collaborator

@burtek Hi. Can you try [email protected]? Is this issue still there?

@burtek
Copy link
Author

burtek commented Oct 18, 2021

Hi. For

return <Scatter data={data} options={options} plugins={[backgroundPlugin]} />;

it works if I do const backgroundPlugin: Plugin = { ... } but doesn't for const backgroundPlugin: Plugin<'scatter'> = { ... } - TS is reporting:

Type 'Plugin<"scatter", AnyObject>[]' is not assignable to type 'Plugin<keyof ChartTypeRegistry, AnyObject>[]'.
  Type 'Plugin<"scatter", AnyObject>' is not assignable to type 'Plugin<keyof ChartTypeRegistry, AnyObject>'.
    Types of property 'beforeTooltipDraw' are incompatible.

I'm fine with Plugin as it doesn't really change much, so the issue seems fixed for me, but just wanted to point this out

dangreen added a commit that referenced this issue Oct 18, 2021
dangreen added a commit that referenced this issue Oct 18, 2021
dangreen added a commit that referenced this issue Oct 18, 2021
* fix: fix components' props types

fix #734, possible fix #741

* ci(size-limit): increase size
@burtek
Copy link
Author

burtek commented Oct 18, 2021

@dangreen @El-bana looks like README needs to be changed, too?
image

@dangreen
Copy link
Collaborator

@burtek Can you try [email protected] ?

@burtek
Copy link
Author

burtek commented Oct 19, 2021

@dangreen So far looks and works good to me :)

@Maks6831
Copy link

<Chart
width={"100%"}
height={"100%"}
type={props.isLine ? "line" : "bar"}
data={data}
options={options as any}
style={{ width: "100%", height: "100%" }}
/> this works for me - the error was failing checks even though the graph was working properly the way i had made it

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

Successfully merging a pull request may close this issue.

4 participants