highcharts-vue icon indicating copy to clipboard operation
highcharts-vue copied to clipboard

Type definitions are incompatible with Vue3

Open j2L4e opened this issue 2 years ago • 8 comments

highcharts-vue.d.ts imports several types that Vue3 no longer exports.

See https://github.com/vuejs/core/issues/1370

node_modules/highcharts-vue/types/highcharts-vue.d.ts:1:23 - error TS2305: Module '"vue"' has no exported member 'PropOptions'.

1 import _Vue, { VNode, PropOptions, WatchOptionsWithHandler, WatchHandler, CreateElement } from "vue";
                        ~~~~~~~~~~~

node_modules/highcharts-vue/types/highcharts-vue.d.ts:1:36 - error TS2305: Module '"vue"' has no exported member 'WatchOptionsWithHandler'.

1 import _Vue, { VNode, PropOptions, WatchOptionsWithHandler, WatchHandler, CreateElement } from "vue";
                                     ~~~~~~~~~~~~~~~~~~~~~~~

node_modules/highcharts-vue/types/highcharts-vue.d.ts:1:61 - error TS2305: Module '"vue"' has no exported member 'WatchHandler'.

1 import _Vue, { VNode, PropOptions, WatchOptionsWithHandler, WatchHandler, CreateElement } from "vue";
                                                              ~~~~~~~~~~~~

node_modules/highcharts-vue/types/highcharts-vue.d.ts:1:75 - error TS2305: Module '"vue"' has no exported member 'CreateElement'.

1 import _Vue, { VNode, PropOptions, WatchOptionsWithHandler, WatchHandler, CreateElement } from "vue";
                                                                            ~~~~~~~~~~~~~

node_modules/highcharts-vue/types/highcharts-vue.d.ts:7:42 - error TS2709: Cannot use namespace '_Vue' as a type.

7     interface ComponentOptions<V extends _Vue> {
                                           ~~~~

node_modules/highcharts-vue/types/highcharts-vue.d.ts:33:28 - error TS2507: Type 'typeof import("/redacted/node_modules/vue/dist/vue")' is not a constructor function type.

33 export class Chart extends _Vue {
                              ~~~~

j2L4e avatar Mar 24 '22 12:03 j2L4e

Hi @j2L4e

Thank you for reporting the problem. Indeed, it looks like the bug which we should resolve immediately, but definitely need to have some time to investigate it. Meanwhile, I'm marking this issue with Bug label.

Kind regards!

Denyllon avatar Mar 29 '22 15:03 Denyllon

@Denyllon, just want to kindly ask if any update on this?

pwang2 avatar Jun 17 '22 17:06 pwang2

Unfortunately it's not resolved yet. I think in this case we need to figure out what we should do with our existing d.ts file, as the latest Vue version has completely different exported members. The most important thing here is to keep this wrapper compatible with both Vue 2 and 3 versions, what could be a bit problematic.

Denyllon avatar Jun 29 '22 15:06 Denyllon

It makes more sense to skip the default loading of d.ts and allow the dev tools to decide which one to load.

pwang2 avatar Jun 29 '22 16:06 pwang2

Do we have an update on this? Would be great to get proper type support for this library.

IceBlizz6 avatar Aug 05 '22 08:08 IceBlizz6

Unfortunately, it's not fixed yet. We'll schedule the work on type definitions soon.

Denyllon avatar Aug 05 '22 13:08 Denyllon

Updates?

georgebohnisch avatar Oct 06 '22 21:10 georgebohnisch

before any fix available. I was adding "postinstall": "rimraf node_modules/highcharts-vue/types" to package.json scripts. and using Hightcharts's 150K lines of typing file. we might just need types for the chartOptions.

pwang2 avatar Oct 06 '22 22:10 pwang2

Any updates? Still encountering this issue.

jaclynt avatar Oct 27 '23 16:10 jaclynt

I've prioritized this issue and put it in our backlog. I will keep you posted.

jszuminski avatar Oct 28 '23 14:10 jszuminski

Still an issue. PR not approved.

rcheung9 avatar Jan 15 '24 19:01 rcheung9

You're right @rcheung9. I'm sorry, but I did not manage to resolve this yet as there have been prioritized Highcharts Export Server issues that I had to look into.

I will try to merge a fix and publish a new version by the end of January.

In the meantime, you can override the default types with these types that I've prepared:

// Types for Vue3
import { DefineComponent, App } from 'vue';
import * as Highcharts from 'highcharts';

export type ChartUpdateArgs = [boolean, boolean, Highcharts.AnimationOptionsObject];

declare module '@vue/runtime-core' {
    export interface ComponentCustomProperties {
        highcharts?: typeof Highcharts;
    }
}

export interface ChartComponentOptions {
    constructorType?: string;
    options?: Highcharts.Options;
    callback?: Highcharts.ChartCallbackFunction;
    updateArgs?: ChartUpdateArgs;
    highcharts?: typeof Highcharts;
    deepCopyOnUpdate?: boolean;
}

export interface ChartProps {
    constructorType?: string;
    options: Highcharts.Options;
    updateArgs?: ChartUpdateArgs;
    callback?: Highcharts.ChartCallbackFunction;
}

export const Chart: DefineComponent<ChartProps>;

export default function install(app: App, options?: ChartComponentOptions): void;

which works well with the latest version of Vue.

jszuminski avatar Jan 15 '24 22:01 jszuminski

this error is related?

image

  "dependencies": {
    "axios": "1.6.7",
    "highcharts": "^11.3.0",
    "highcharts-vue": "^1.4.3",
    "moment": "^2.30.1",
    "vue": "^3.4.15",
    "vue-router": "^4.0.11"
  },

Pedrocanoas avatar Feb 07 '24 14:02 Pedrocanoas

Yes @Pedrocanoas, this comment might be related if you're using TypeScript. I have created a new branch for a Vue3 full support release: https://github.com/highcharts/highcharts-vue/pull/258 which I schedule for this week.

jszuminski avatar Feb 08 '24 11:02 jszuminski

@Pedrocanoas did not manage to release it yet, currently on the testing phase. Feel free to install the beta version from the GitHub branch like this:

"dependencies": {
    "vue": "^3.4.15",
    "highcharts": "10.3.3",
    "highcharts-vue": "https://github.com/highcharts/highcharts-vue.git#vue3/types"
  },

Everything should work as expected, but please try it out and let me know about your experience.

jszuminski avatar Feb 13 '24 12:02 jszuminski

Hi @jakubSzuminski, I was facing same issue and your beta version solved all issues!

mcenkar avatar Feb 13 '24 13:02 mcenkar

@jakubSzuminski The feature branch version works like a charm for me! Any idea when the new version will be out so I can update the dependency version?

hexagon06 avatar Mar 01 '24 10:03 hexagon06

We've just released v2.0.0. Closing via https://github.com/highcharts/highcharts-vue/pull/258.

Please let me know if there's anything that does not work as expected. We'll try to fix it asap.

jszuminski avatar Mar 06 '24 09:03 jszuminski