visjs / vis-timeline

📅 Create a fully customizable, interactive timelines and 2d-graphs with items and ranges.
https://visjs.github.io/vis-timeline/
Other
1.88k stars 315 forks source link

Timeline: Cannot use typescript > 4.7 #1530

Closed Valentin-MF closed 11 months ago

Valentin-MF commented 2 years ago

I import vis-data and vis-timeline into a typescript application. Since I upgraded Typescript from 4.7.x to 4.8.x, I get this error: image

Mariissa commented 1 year ago

Have the same error, do we have a solution?

Valentin-MF commented 1 year ago

While waiting for a correction I don't use the types from the library anymore.

Mariissa commented 1 year ago

How can I do it as well?

While waiting for a correction I don't use the types from the library anymore.

Mariissa commented 1 year ago

From where you take your imports?

Valentin-MF commented 1 year ago

It depends on your project. I use angular so I added the standalone scripts in the scripts section of angular.json and in the typescript I don't import anything from the library, I just use globalThis.vis.

Like this:

angular.json:

...
    "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "scripts": [
              "./node_modules/vis-data/standalone/umd/vis-data.min.js",
              "./node_modules/vis-util/standalone/umd/vis-util.min.js",
              "./node_modules/vis-timeline/standalone/umd/vis-timeline-graph2d.min.js"
            ]
          },
...

Usage in my angular component: let timeline = new globalThis.vis.Timeline(...)

Mariissa commented 1 year ago

Cool, I am using Angular too, just made the upgrade and got this errors. Could you explain me please how do you declare vis inside globalThis?

Valentin-MF commented 1 year ago

Nothing to do. It's done in the standalone version.

BoJIbFbI4 commented 1 year ago

Hi Valentin-MF, can u show ur typings/global.d.ts ? it's will help me a lot.

Valentin-MF commented 1 year ago

I don't have global.d.ts

Valentin-MF commented 1 year ago

You may need to remove noImplicitAny in your tsconfig.json.

slavede commented 1 year ago

I have also changed code not to use the typings now and importing raw .js, but in my opinion, it's not the best solution.

It would be great if this gets in somehow, just typing update is needed I believe.

duckyb commented 1 year ago

Another possible workaround is to add: "skipLibCheck": true, to your tsconfig.json

slavede commented 1 year ago

But this would apply it for every lib, I really wouldn't like that.

jonybekov commented 1 year ago

Any workarounds?

Valentin-MF commented 11 months ago

Since the latest version of vis-util (https://github.com/visjs/vis-util/releases/tag/v5.0.6) and after adding the @egjs/hammerjs package (2.0.17) to my devDependencies, my typescript compilation no longer encounters errors.