Skip to content

UpdateModeEnum - enum collision when using chartjs@4.2.0 & chartjs-plugin-zoom@2.0.0 #735

@infrat

Description

@infrat

Hello.

I have an angular project where I'm using chart.js@4.2.0 and I'm trying to integrate chartjs-plugin-zoom@2.0.0.
After importing chartjs-plugin-zoom into component where I'm setting up instance of chart.js, I'm getting error as follows:

Error: node_modules/chart.js/dist/types/index.d.ts:570:21 - error TS2567: Enum declarations can only merge with namespace or other enum declarations.

570 export declare enum UpdateModeEnum {
                        ~~~~~~~~~~~~~~

  node_modules/chartjs-plugin-zoom/types/index.d.ts:16:14
    16   const enum UpdateModeEnum {
                    ~~~~~~~~~~~~~~
    'UpdateModeEnum' was also declared here.


Error: node_modules/chartjs-plugin-zoom/types/index.d.ts:16:14 - error TS2567: Enum declarations can only merge with namespace or other enum declarations.

16   const enum UpdateModeEnum {
                ~~~~~~~~~~~~~~

  node_modules/chart.js/dist/types/index.d.ts:570:21
    570 export declare enum UpdateModeEnum {
                            ~~~~~~~~~~~~~~
    'UpdateModeEnum' was also declared here.




✖ Failed to compile.

Changing const enum to enum in node_modules/chartjs-plugin-zoom/types/index.d.ts@16 makes the compilation successful in my case. It seems that this change has been introduced in this PR: https://github.com/chartjs/chartjs-plugin-zoom/pull/695/files#diff-093ad82a25aee498b11febf1cdcb6546e4d223ffcb49ed69cc275ac27ce0ccceL16

All the dependencies in my project I have in my package.json:

"dependencies": {
    "@angular/animations": "^15.1.5",
    "@angular/common": "^15.1.5",
    "@angular/compiler": "^15.1.5",
    "@angular/core": "^15.1.5",
    "@angular/forms": "^15.1.5",
    "@angular/localize": "^15.1.5",
    "@angular/platform-browser": "^15.1.5",
    "@angular/platform-browser-dynamic": "^15.1.5",
    "@angular/router": "^15.1.5",
    "@ng-bootstrap/ng-bootstrap": "^14.0.1",
    "@popperjs/core": "^2.10.2",
    "@types/w3c-web-serial": "^1.0.3",
    "bootstrap": "^5.2.0",
    "chart.js": "^4.2.1",
    "chartjs-plugin-annotation": "^2.1.2",
    "chartjs-plugin-zoom": "^2.0.0",
    "ng-event-bus": "^5.1.0",
    "ng2-charts": "^4.1.1",
    "rxjs": "~7.5.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.11.4"
  },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions