]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Correct type for updateHoverStyle (#10131)
authorEvert Timberg <evert.timberg@gmail.com>
Sat, 5 Feb 2022 14:26:31 +0000 (09:26 -0500)
committerGitHub <noreply@github.com>
Sat, 5 Feb 2022 14:26:31 +0000 (09:26 -0500)
* Correct type for updateHoverStyle
* Lint fixes

types/index.esm.d.ts
types/tests/interaction.ts [new file with mode: 0644]

index 6bf0ae14753e4ddc2e5e65cf22b38cc692c866ca..c8993984ee37de314424a226685d73706a72844b 100644 (file)
@@ -529,7 +529,7 @@ export declare class Chart<
   toBase64Image(type?: string, quality?: unknown): string;
   bindEvents(): void;
   unbindEvents(): void;
-  updateHoverStyle(items: Element, mode: 'dataset', enabled: boolean): void;
+  updateHoverStyle(items: InteractionItem[], mode: 'dataset', enabled: boolean): void;
 
   notifyPlugins(hook: string, args?: AnyObject): boolean | void;
 
diff --git a/types/tests/interaction.ts b/types/tests/interaction.ts
new file mode 100644 (file)
index 0000000..e5df1da
--- /dev/null
@@ -0,0 +1,17 @@
+import {
+  Chart, ChartData, ChartConfiguration, Element
+} from '../index.esm';
+
+const data: ChartData<'line'> = { datasets: [] };
+const chartItem = 'item';
+const config: ChartConfiguration<'line'> = { type: 'line', data };
+const chart: Chart = new Chart(chartItem, config);
+
+type Item = {
+  element: Element,
+  datasetIndex: number,
+  index: number
+}
+
+const elements: Item[] = [];
+chart.updateHoverStyle(elements, 'dataset', true);