Skip to content

Commit

Permalink
Give elements their own interface definition (#8290)
Browse files Browse the repository at this point in the history
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]: chartjs/chartjs-plugin-annotation#275 (comment)
[2]: https://www.typescriptlang.org/docs/handbook/declaration-merging.html
  • Loading branch information
joshkel committed Jan 30, 2021
1 parent bc312d0 commit 5eb3682
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions types/index.esm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5eb3682

Please sign in to comment.