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

Module '"chart.js"' has no exported member 'SubTitle'. #9383

Closed
mfriesen opened this issue Jul 9, 2021 · 8 comments · Fixed by #9386
Closed

Module '"chart.js"' has no exported member 'SubTitle'. #9383

mfriesen opened this issue Jul 9, 2021 · 8 comments · Fixed by #9386
Labels
type: bug type: types Typescript type changes

Comments

@mfriesen
Copy link

mfriesen commented Jul 9, 2021

Expected Behavior

Using Chart.js v3.4.1 in an angular application, I expect that I can use the new options.plugins.SubTitle feature

import { SubTitle } from 'chart.js'; to then allow
Chart.register(SubTitle);

I should not get an error when trying to use SubTitle.

Current Behavior

I am getting the error Module '"chart.js"' has no exported member 'SubTitle'.

Possible Solution

I suspect either it is not called "SubTitle" or it is not being exported.

Steps to Reproduce

Following the https://www.chartjs.org/docs/next/getting-started/integration.html (Bundlers (Webpack, Rollup, etc.)), try and register the "SubTitle" module.

When using
import { registerables } from 'chart.js';
Chart.register(...registerables);

SubTitle work perfectly, but this will load all plugins which is not ideal.

Context

I am required to load all plugins and not just the ones I need.

Environment

  • Chart.js version: 3.4.1
@etimberg
Copy link
Member

etimberg commented Jul 9, 2021

I looked into the built file and see the plugin being exported as SubTitle. Do you have a reproduce for this?

@LeeLenaleee
Copy link
Collaborator

Seems to work fine: https://codesandbox.io/s/admiring-ardinghelli-wk15h?file=/src/components/HelloWorld.vue

@etimberg
Copy link
Member

etimberg commented Jul 9, 2021

I do see that there isn't a type of SubTitle so perhaps this is a TS error?

@mfriesen
Copy link
Author

mfriesen commented Jul 9, 2021

@LeeLenaleee Thanks for the VUE example. I was able to create an angular one that shows the error I'm seeing. https://codesandbox.io/s/sharp-swanson-r5qpk?file=/src/main.ts

@mfriesen
Copy link
Author

mfriesen commented Jul 9, 2021

@LeeLenaleee If I used "registerables" instead of "SubTitle" then everything works fine, but it load all the ChartJS modules.

@LeeLenaleee
Copy link
Collaborator

As @etimberg suspected its a type error which should be rsolved by his pr
image

@etimberg
Copy link
Member

etimberg commented Jul 9, 2021

This is a pure TS error. You can add a TS ignore and it will be fine until a fix is released

@etimberg etimberg added type: types Typescript type changes and removed status: needs test case labels Jul 9, 2021
@etimberg etimberg linked a pull request Jul 9, 2021 that will close this issue
@mfriesen
Copy link
Author

Yes changing it to
import {
// @ts-ignore
SubTitle
} from 'chart.js'

fixed the problem.

Thanks so much for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug type: types Typescript type changes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants