From: Josh Kelley Date: Sat, 30 Jan 2021 19:48:18 +0000 (-0500) Subject: Give elements their own interface definition (#8290) X-Git-Tag: v3.0.0-beta.10~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5eb3682b9fbb27bb05a9d4b53a8c30ecb73e9f50;p=thirdparty%2FChart.js.git Give elements their own interface definition (#8290) From what I understand, if we want to allow registering additional element options (see [here][1] for an example), then the element options need to be a top-level interface so that they can be used with TypeScript's [declaration merging][2]. [1]: https://github.com/chartjs/chartjs-plugin-annotation/pull/275#issuecomment-742754562 [2]: https://www.typescriptlang.org/docs/handbook/declaration-merging.html --- diff --git a/types/index.esm.d.ts b/types/index.esm.d.ts index cf2d6dd50..9fafa6b16 100644 --- a/types/index.esm.d.ts +++ b/types/index.esm.d.ts @@ -1840,14 +1840,16 @@ export const BarElement: ChartComponent & { new (cfg: any): BarElement; }; +export interface ElementOptions { + arc: ArcOptions & ArcHoverOptions; + bar: BarOptions & BarHoverOptions; + line: LineOptions & LineHoverOptions; + point: PointOptions & PointHoverOptions; +} export interface ElementChartOptions { - elements: { - arc: ArcOptions & ArcHoverOptions; - bar: BarOptions & BarHoverOptions; - line: LineOptions & LineHoverOptions; - point: PointOptions & PointHoverOptions; - }; + elements: ElementOptions; } + export class BasePlatform { /** * Called at chart construction time, returns a context2d instance implementing