From 5eb3682b9fbb27bb05a9d4b53a8c30ecb73e9f50 Mon Sep 17 00:00:00 2001 From: Josh Kelley Date: Sat, 30 Jan 2021 14:48:18 -0500 Subject: [PATCH] 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 --- types/index.esm.d.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/types/index.esm.d.ts b/types/index.esm.d.ts index cf2d6dd50eb..9fafa6b16a0 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