Skip to content

Commit

Permalink
added better typescript support
Browse files Browse the repository at this point in the history
  • Loading branch information
jerairrest committed Aug 15, 2017
1 parent c078387 commit c698b78
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
34 changes: 15 additions & 19 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Type definitions for react-chartjs-2 2.0
// Project: https://github.com/gor181/react-chartjs-2
// Project: https://github.com/jerairrest/react-chartjs-2
// Definitions by: Alexandre Paré <https://github.com/apare>
// Fabien Lavocat <https://github.com/FabienLavocat>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
Expand All @@ -8,7 +8,9 @@
import * as React from "react";
import * as chartjs from "chart.js";

export type ChartDataFunction<T extends chartjs.ChartData> = (element: HTMLElement) => T;
export type ChartDataFunction<T extends chartjs.ChartData> = (
element: HTMLElement
) => T;
export type ChartData<T extends chartjs.ChartData> = ChartDataFunction<T> | T;

export interface ChartComponentProps {
Expand All @@ -29,30 +31,24 @@ export interface LinearComponentProps extends ChartComponentProps {
data: ChartData<chartjs.ChartData>;
}

export default class ChartComponent<P extends ChartComponentProps> extends React.Component<P> {
export default class ChartComponent<
P extends ChartComponentProps
> extends React.Component<P> {
chart_instance: chartjs;
}

export class Doughnut extends ChartComponent<ChartComponentProps> {
}
export class Doughnut extends ChartComponent<ChartComponentProps> {}

export class Pie extends ChartComponent<ChartComponentProps> {
}
export class Pie extends ChartComponent<ChartComponentProps> {}

export class Line extends ChartComponent<LinearComponentProps> {
}
export class Line extends ChartComponent<LinearComponentProps> {}

export class Bar extends ChartComponent<LinearComponentProps> {
}
export class Bar extends ChartComponent<LinearComponentProps> {}

export class HorizontalBar extends ChartComponent<ChartComponentProps> {
}
export class HorizontalBar extends ChartComponent<ChartComponentProps> {}

export class Radar extends ChartComponent<ChartComponentProps> {
}
export class Radar extends ChartComponent<ChartComponentProps> {}

export class Polar extends ChartComponent<ChartComponentProps> {
}
export class Polar extends ChartComponent<ChartComponentProps> {}

export class Bubble extends ChartComponent<ChartComponentProps> {
}
export class Bubble extends ChartComponent<ChartComponentProps> {}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "react-chartjs-2",
"version": "2.5.6",
"version": "2.5.7",
"description": "react-chartjs-2",
"main": "lib/index.js",
"author": "Goran Udosic",
"author": "Jeremy Ayerst",
"homepage": "https://github.com/jerairrest/react-chartjs-2",
"repository": {
"type": "git",
Expand Down

0 comments on commit c698b78

Please sign in to comment.