highcharts / highcharts-vue

Other
686 stars 150 forks source link

issue with types in 2.0.0 #259

Closed b-maslennikov closed 8 months ago

b-maslennikov commented 8 months ago

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

b-maslennikov commented 8 months ago

image one more custom component

matthew-dean commented 8 months ago

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.

jszuminski commented 8 months ago

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.

matthew-dean commented 8 months ago

@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!

b-maslennikov commented 8 months ago

checked PNPM fix - works perfect to me thanks

jszuminski commented 8 months ago

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

jszuminski commented 8 months ago

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.

b-maslennikov commented 8 months ago

hmm. latest version on npm is still 2.0.0

jszuminski commented 8 months ago

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
b-maslennikov commented 8 months ago

perfect. thanks mate