highcharts / highcharts-vue

Other
686 stars 150 forks source link

adds registerGlobalComponents example for ts project #191

Closed zanuka closed 2 years ago

zanuka commented 3 years ago

I thought this might be helpful in the readme.

zanuka commented 3 years ago

The global config approach I added to the readme isn't working for me in a project where sub components contain their own chart. I'm still having to import as usual:
import { Chart } from 'highcharts-vue';

components: {
  highchart: Chart,
},

I ended up just having to disable lint:tsc from my build script because it would keep throwing this when running into the template tag

error TS2322: Type '{ id: string; class: string; options: { accessibility?: { announceNewData?: { announcementFormatter?: AccessibilityAnnouncementFormatter | undefined; enabled?: boolean | undefined; interruptUser?: boolean | undefined; minAnnounceInterval?: number | undefined; } | undefined; ... 10 more ...; typeDescription?: string ...' is not assignable to type 'typeof Chart & Omit<__VLS_GlobalAttrs, "prototype"> & Record<string, unknown>'.
  Property 'prototype' is missing in type '{ id: string; class: string; options: { accessibility?: { announceNewData?: { announcementFormatter?: AccessibilityAnnouncementFormatter | undefined; enabled?: boolean | undefined; interruptUser?: boolean | undefined; minAnnounceInterval?: number | undefined; } | undefined; ... 10 more ...; typeDescription?: string ...' but required in type 'typeof Chart'.

15     <highchart

I still think the readme addition for global component registration might help some.