Skip to content

[3.0.0-beta.3] TypeScript issue when building #7838

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

Closed
santam85 opened this issue Oct 2, 2020 · 3 comments · Fixed by #7841
Closed

[3.0.0-beta.3] TypeScript issue when building #7838

santam85 opened this issue Oct 2, 2020 · 3 comments · Fixed by #7841
Labels
type: bug type: types Typescript type changes

Comments

@santam85
Copy link

santam85 commented Oct 2, 2020

  • Chart.js version: 3.0.0-beta.3
  • TypeScript version: 3.9.7

When attempting to build a TypeScript project importing chart.js, I get the following error when building:

ERROR: node_modules/chart.js/dist/chunks/index.d.ts:1291:1 - error TS1046: Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier.

1291 enum ScaleTypeEnum {
     ~~~~

An unhandled exception occurred: node_modules/chart.js/dist/chunks/index.d.ts:1291:1 - error TS1046: Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier.

1291 enum ScaleTypeEnum {
     ~~~~

Seems to be related to this long-standing issue in TypeScript: microsoft/TypeScript#3792

@santam85 santam85 changed the title TypeScript issue when building [3.0.0-beta.3] TypeScript issue when building Oct 2, 2020
@etimberg etimberg added the type: types Typescript type changes label Oct 2, 2020
@etimberg
Copy link
Member

etimberg commented Oct 2, 2020

Thanks for reporting this @santam85. When you get the error, what are you importing from Chart.js? I have a project written in Typescript (v3.7.5) that uses Chart.js and I did not run into this when upgrading to beta.3.

@xr0master
Copy link
Contributor

@santam85 use skipLibCheck flag for TS.
@etimberg he is right, we have this issue here. Need to add declare keyword for enums.

@emmcb
Copy link
Contributor

emmcb commented Oct 2, 2020

In fact now I added the registry interfaces, I think we can get rid of enum completely and simply use the registry keys. I will propose a PR in this direction.

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.

4 participants