]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Give elements their own interface definition (#8290)
authorJosh Kelley <joshkel@gmail.com>
Sat, 30 Jan 2021 19:48:18 +0000 (14:48 -0500)
committerGitHub <noreply@github.com>
Sat, 30 Jan 2021 19:48:18 +0000 (14:48 -0500)
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

index cf2d6dd50eb55d116a5aa7cca034bfb94ea3be8e..9fafa6b16a0bcbeb60617f49c0f64c2e20e17092 100644 (file)
@@ -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