highcharts/highcharts-vue

issue with types in 2.0.0

b-maslennikov opened this issue · 10 comments

I started getting this error in VSC and during the build since updated to 2.0.0

Argument of type '{}' is not assignable to parameter of type 'Partial<{}> & Omit<{ readonly constructorType?: string | undefined; readonly options: Options; readonly callback?: ChartCallbackFunction | undefined; readonly updateArgs?: ChartUpdateArgs | undefined; readonly highcharts?: typeof import("...'.
  Property 'options' is missing in type '{}' but required in type 'Omit<{ readonly constructorType?: string | undefined; readonly options: Options; readonly callback?: ChartCallbackFunction | undefined; readonly updateArgs?: ChartUpdateArgs | undefined; readonly highcharts?: typeof import("...'.ts-plugin(2345)
highcharts-vue.d.ts(7, 5): 'options' is declared here.

image

<loading-bar /> is my (custom) component. it's defined globaly. it does not use highcharts-vue

image
one more custom component

I also discovered this. For some reason, this library defines ALL components as Chart components. You can see the issue right here:

declare module '@vue/runtime-core' {
    export interface GlobalComponents {
        [key: string]: DefineComponent<ChartProps, {}, {}>
    }
}

This section aggressively defines all global components as having ChartProps. Not sure why they did this. A short-term fix would be to use pnpm patch or patch-package to remove these lines.

Thanks for reporting! You're absolutely right. I've prepared a simple fix, could you please check if this works as expected?

[package.json]
"dependencies": {
    "highcharts": "10.3.3",
    "highcharts-vue": "https://github.com/highcharts/highcharts-vue.git#bug/259-global-types-problem"
  },

If yes, I will merge it and release v2.1.0.

@jszuminski PNPM only works with this NPM format:

"highcharts-vue": "github:highcharts/highcharts-vue.git#bug/259-global-types-problem"

(See: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#repository and this issue)

That said, it seems to work. Thanks!

checked PNPM fix - works perfect to me
thanks

I'm reopening this issue for now as I need to publish it to npm with v2.1.0 :)

Published v2.0.1 on npm, this should no longer be a problem. Please feel free to report any more issues in case you find any, I will try to solve them asap.

hmm. latest version on npm is still 2.0.0

I've authenticated the npm publish now and it should be there in the registry so feel free to use it and report any issues that you encounter or potential features/enhancements.
Screenshot 2024-03-15 at 11 28 45

perfect. thanks mate