Skip to content

Commit

Permalink
Fix TS default export of the plugin instance
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbrunel committed May 5, 2019
1 parent de08e5b commit 92771df
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
8 changes: 6 additions & 2 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Options } from './options';

export * from './context';

declare module 'chart.js' {
interface ChartDataSets {
/**
Expand All @@ -19,3 +17,9 @@ declare module 'chart.js' {
datalabels?: Options
}
}

declare const plugin: object;

export * from './context';

export default plugin;
21 changes: 21 additions & 0 deletions types/test/exports.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// https://github.com/chartjs/chartjs-plugin-datalabels/issues/130
import { Chart } from 'chart.js'
import { Context } from '../index'
import Plugin from '../index'

// Plugin instance
Chart.plugins.register(Plugin)
Chart.plugins.unregister(Plugin)

const chart = new Chart('id', {
plugins: [Plugin]
})

// Scriptable context
const ctx: Context = {
active: true,
chart: chart,
datasetIndex: 0,
dataIndex: 0,
dataset: {}
}

0 comments on commit 92771df

Please sign in to comment.