From 184be5c432404c44f58e29914dcbfd19f584b1f7 Mon Sep 17 00:00:00 2001 From: Jakub Date: Mon, 16 Jul 2018 12:11:33 +0200 Subject: [PATCH] feat(typescript): Add basic typescript definitions Adds basic type definitions - Fixes #376 --- package.json | 4 +++- types/components.d.ts | 7 +++++++ types/index.d.ts | 19 +++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 types/components.d.ts create mode 100644 types/index.d.ts diff --git a/package.json b/package.json index 0efacb91..9e609768 100644 --- a/package.json +++ b/package.json @@ -40,10 +40,12 @@ "unpkg": "dist/vue-chartjs.min.js", "module": "es/index.js", "jsnext:main": "es/index.js", + "typings": "types/index.d.ts", "files": [ "src", "dist", - "es" + "es", + "types/*.d.ts" ], "scripts": { "dev": "node build/dev-server.js", diff --git a/types/components.d.ts b/types/components.d.ts new file mode 100644 index 00000000..acf2ea8e --- /dev/null +++ b/types/components.d.ts @@ -0,0 +1,7 @@ +import Vue from 'vue' + +/** vue-chartjs component common definition */ +export declare class BaseChart extends Vue { + addPlugin (plugin?: string[]): void + renderChart (chartData: any, options?: any): void +} diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 00000000..e9626eb9 --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,19 @@ +import { BaseChart } from './components' + +declare module 'vue-chartjs' { + export function generateChart(chartId: string, chartType: string): any; + export class Bar extends BaseChart {} + export class HorizontalBar extends BaseChart {} + export class Doughnut extends BaseChart {} + export class Line extends BaseChart {} + export class Pie extends BaseChart {} + export class PolarArea extends BaseChart {} + export class Radar extends BaseChart {} + export class Bubble extends BaseChart {} + export class Scatter extends BaseChart {} + export const mixins: { + reactiveData: any + reactiveProp: any + } +} +