diff --git a/ember-highcharts/src/components/high-charts.ts b/ember-highcharts/src/components/high-charts.ts index 85897cf..3bc6dc5 100644 --- a/ember-highcharts/src/components/high-charts.ts +++ b/ember-highcharts/src/components/high-charts.ts @@ -25,7 +25,7 @@ const CHART_TYPES = { undefined: 'chart', } as const; -interface HighChartsSignature { +interface HighChartsSignature { Element: HTMLDivElement; Args: { /** @@ -36,7 +36,7 @@ interface HighChartsSignature { * The `content` argument matches up with the `series` option in the Highcharts/Highstock/Highmaps API. * Use this option to set the series data for your chart. */ - content?: Highcharts.Options['series']; + content?: Content; /** * The `chartOptions` argument is a generic object for setting different options with Highcharts/Highstock/Highmaps. * Use this option to set things like the chart title and axis settings. @@ -56,7 +56,9 @@ interface HighChartsSignature { }; } -export default class HighCharts extends Component { +export default class HighCharts< + Content extends Highcharts.Options['series'], +> extends Component> { get content() { return this.args.content ?? undefined; } @@ -121,9 +123,9 @@ export default class HighCharts extends Component { onDidUpdate( _elem: unknown, [content, chartOptions, mode]: [ - HighChartsSignature['Args']['content'], - HighChartsSignature['Args']['chartOptions'], - HighChartsSignature['Args']['mode'], + HighChartsSignature['Args']['content'], + HighChartsSignature['Args']['chartOptions'], + HighChartsSignature['Args']['mode'], ], ) { const { chart } = this; diff --git a/ember-highcharts/src/utils/build-options.ts b/ember-highcharts/src/utils/build-options.ts index fc9ce8a..2db4ec0 100644 --- a/ember-highcharts/src/utils/build-options.ts +++ b/ember-highcharts/src/utils/build-options.ts @@ -9,10 +9,12 @@ export const EMPTY_CHART_CONTENT = [ }, ] as const; -export default function buildOptions( +export default function buildOptions< + Content extends Highcharts.Options['series'], +>( theme: Highcharts.Options = {}, options: Highcharts.Options = {}, - content?: Highcharts.Options['series'], + content?: Content, ) { // if 'no-data-to-display' module has been imported, keep empty series // and leave it to highcharts to show no data label. diff --git a/ember-highcharts/src/utils/chart-data.ts b/ember-highcharts/src/utils/chart-data.ts index c165677..b057b95 100644 --- a/ember-highcharts/src/utils/chart-data.ts +++ b/ember-highcharts/src/utils/chart-data.ts @@ -1,12 +1,14 @@ import type Highcharts from 'highcharts'; -export function getSeriesMap(seriesGroup: Array) { +export function getSeriesMap( + seriesGroup: Array, +) { const seriesMap = seriesGroup.reduce( (seriesMap, seriesItem) => { seriesMap[seriesItem.name as string] = seriesItem; return seriesMap; }, - {} as { [key: string]: Highcharts.SeriesOptionsType }, + {} as { [key: string]: Content }, ); return seriesMap;