Skip to content

Commit

Permalink
Give elements their own interface definition
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 8, 2021
1 parent e63beb8 commit fb49cc5
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 @@ -1834,14 +1834,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 fb49cc5

Please sign in to comment.