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

Cannot build project using chartjs if TypeScript compiler option isolatedModules is set to true #11094

Closed
jljouannic opened this issue Jan 27, 2023 · 0 comments · Fixed by #11095

Comments

@jljouannic
Copy link
Contributor

jljouannic commented Jan 27, 2023

Expected behavior

In a project embedding chart.js, the TypeScript transpilation with the following options works successfully:

  • "isolatedModules": true,
  • "skipLibCheck": false.

Current behavior

Transpilation fails because of en exported const enum:

node_modules/chart.js/dist/types/index.d.ts:579:39 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

579 export type UpdateMode = keyof typeof UpdateModeEnum;
                                          ~~~~~~~~~~~~~~


Found 1 error in node_modules/chart.js/dist/types/index.d.ts:579

More explanation here: https://ncjamieson.com/dont-export-const-enums/

Reproducible sample

https://stackblitz.com/edit/vitejs-vite-y2wwyb?file=tsconfig.json

Optional extra steps/info to reproduce

Take a look at the terminal at the bottom of the page to see the transpilation error

Possible solution

Make UpdateModeEnum a simple enum, not a const one maybe.

Context

No response

chart.js version

v4.2.0

Browser name and version

No response

Link to your project

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant