From bda2ae7c4f28d3a05d860eab0688c824cb72f067 Mon Sep 17 00:00:00 2001 From: stockiNail Date: Wed, 26 Jul 2023 14:59:42 +0200 Subject: [PATCH] Revert feature to disable plugins by TS (#11422) --- docs/developers/plugins.md | 2 +- src/types/index.d.ts | 14 +++++++------- test/types/defaults.ts | 6 +++--- test/types/overrides.ts | 4 ++-- test/types/plugins/defaults.ts | 5 ++--- test/types/plugins/disable.ts | 16 ---------------- .../tooltip_parsed_data_chart_defaults.ts | 4 ++-- 7 files changed, 17 insertions(+), 34 deletions(-) delete mode 100644 test/types/plugins/disable.ts diff --git a/docs/developers/plugins.md b/docs/developers/plugins.md index 4468a58f52e..60747416b91 100644 --- a/docs/developers/plugins.md +++ b/docs/developers/plugins.md @@ -197,7 +197,7 @@ declare module 'chart.js' { interface PluginOptionsByType { customCanvasBackgroundColor?: { color?: string - } | false + } } } ``` diff --git a/src/types/index.d.ts b/src/types/index.d.ts index 0eb9b5eb679..5cf2d0cc902 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -2929,13 +2929,13 @@ export interface TooltipItem { } export interface PluginOptionsByType { - colors: ColorsPluginOptions | false; - decimation: DecimationOptions | false; - filler: FillerOptions | false; - legend: LegendOptions | false; - subtitle: TitleOptions | false; - title: TitleOptions | false; - tooltip: TooltipOptions | false; + colors: ColorsPluginOptions; + decimation: DecimationOptions; + filler: FillerOptions; + legend: LegendOptions; + subtitle: TitleOptions; + title: TitleOptions; + tooltip: TooltipOptions; } export interface PluginChartOptions { plugins: PluginOptionsByType; diff --git a/test/types/defaults.ts b/test/types/defaults.ts index d20415df1ca..84071849245 100644 --- a/test/types/defaults.ts +++ b/test/types/defaults.ts @@ -1,8 +1,8 @@ -import { Chart, TitleOptions, TooltipOptions } from '../../src/types.js'; +import { Chart } from '../../src/types.js'; Chart.defaults.scales.time.time.minUnit = 'day'; -(Chart.defaults.plugins.title as TitleOptions).display = false; +Chart.defaults.plugins.title.display = false; Chart.defaults.datasets.bar.backgroundColor = 'red'; @@ -27,4 +27,4 @@ Chart.defaults.layout = { }, }; -(Chart.defaults.plugins.tooltip as TooltipOptions).boxPadding = 3; +Chart.defaults.plugins.tooltip.boxPadding = 3; diff --git a/test/types/overrides.ts b/test/types/overrides.ts index 9085dd98356..b4da296a322 100644 --- a/test/types/overrides.ts +++ b/test/types/overrides.ts @@ -1,8 +1,8 @@ -import { Chart, TitleOptions } from '../../src/types.js'; +import { Chart } from '../../src/types.js'; Chart.overrides.bar.scales.x.type = 'time'; -(Chart.overrides.bar.plugins.title as TitleOptions).display = false; +Chart.overrides.bar.plugins.title.display = false; Chart.overrides.line.datasets.bar.backgroundColor = 'red'; diff --git a/test/types/plugins/defaults.ts b/test/types/plugins/defaults.ts index a11c4dce09a..55a08ac7ad8 100644 --- a/test/types/plugins/defaults.ts +++ b/test/types/plugins/defaults.ts @@ -1,9 +1,8 @@ -import { defaults, LegendOptions } from '../../../src/types.js'; +import { defaults } from '../../../src/types.js'; // https://github.com/chartjs/Chart.js/issues/8711 -const original = (defaults.plugins.legend as LegendOptions<"line">).labels.generateLabels; +const original = defaults.plugins.legend.labels.generateLabels; -// @ts-ignore defaults.plugins.legend.labels.generateLabels = function(chart) { return [{ datasetIndex: 0, diff --git a/test/types/plugins/disable.ts b/test/types/plugins/disable.ts deleted file mode 100644 index d6ed066e192..00000000000 --- a/test/types/plugins/disable.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Chart } from '../../../src/types.js'; - -const chart = new Chart('id', { - type: 'bubble', - data: { - labels: [], - datasets: [{ - data: [] - }] - }, - options: { - plugins: { - legend: false - } - } -}); \ No newline at end of file diff --git a/test/types/plugins/plugin.tooltip/tooltip_parsed_data_chart_defaults.ts b/test/types/plugins/plugin.tooltip/tooltip_parsed_data_chart_defaults.ts index b5584adeb43..5072824bcf9 100644 --- a/test/types/plugins/plugin.tooltip/tooltip_parsed_data_chart_defaults.ts +++ b/test/types/plugins/plugin.tooltip/tooltip_parsed_data_chart_defaults.ts @@ -1,6 +1,6 @@ -import { Chart, TooltipOptions } from '../../../../src/types.js'; +import { Chart } from '../../../../src/types.js'; -(Chart.overrides.bubble.plugins.tooltip as TooltipOptions<'bubble'>).callbacks.label = (item) => { +Chart.overrides.bubble.plugins.tooltip.callbacks.label = (item) => { const { x, y, _custom: r } = item.parsed; return `${item.label}: (${x}, ${y}, ${r})`; };