-
Notifications
You must be signed in to change notification settings - Fork 324
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
Invalid typing probably? #901
Comments
@aafanasev-shell The The To access to the label options, you should cast it to const lblOpts = ctx.element.label.options as LabelAnnotationOptions;
lblOpts.content = 'ciao'; Maybe we could create a specific type for label property but a casting should be anyway needed (I'm not TS expert, sorry). |
Afaik in general if you have to typecast something in TS, something is wrong with typing in system that made it so TS can't infer the type 🤔 |
Could agree with you 😉 I think in the future the plugin will be written in TS and probably this will change. I also agree with you that in new major version a review of the types would be needed, maybe introducing generics. |
Hello again!
I saw lot's of usage of
EventContext.element
here and there in examples and tests.e.g. [here](https://github.com/chartjs/chartjs-plugin-annotation/blob/ebd5c6f9c2f56dcf1cf213aa7af2a9e93d38059f/test/fixtures/ellipse/label-dynamic.js#L34C1-L35C1:
But in typings I see that
label
is marked asAnnotationElement
here.Idk, did I understand it correctly, but I believe it should be CoreLabelOptions or smth similar?
I believe typing checker or eslint passes successfully because lot's of properties have the same name. But if you try to replace the code in the example above to:
you'll see an error since
element.label.options
is not type ofAnnotationOptions
But maybe that's just things are mixed up in my head a bit 🙂
The text was updated successfully, but these errors were encountered: