From 8003653dc1cfca653f08cd37705872ac8aad4087 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 5 Feb 2022 21:09:15 -0500 Subject: [PATCH] Ensure that min/max of TimeScaleOptions can be a string --- types/index.esm.d.ts | 9 ++------ types/tests/scales/time_string_max.ts | 30 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 types/tests/scales/time_string_max.ts diff --git a/types/index.esm.d.ts b/types/index.esm.d.ts index 10ac49f4ef5..6e8cb307b97 100644 --- a/types/index.esm.d.ts +++ b/types/index.esm.d.ts @@ -3088,7 +3088,7 @@ export interface CartesianScaleOptions extends CoreScaleOptions { }; } -export type CategoryScaleOptions = CartesianScaleOptions & { +export type CategoryScaleOptions = Omit & { min: string | number; max: string | number; labels: string[] | string[][]; @@ -3107,7 +3107,6 @@ export type LinearScaleOptions = CartesianScaleOptions & { * @default true */ beginAtZero: boolean; - /** * Adjustment used when calculating the maximum data value. */ @@ -3151,7 +3150,6 @@ export const LinearScale: ChartComponent & { }; export type LogarithmicScaleOptions = CartesianScaleOptions & { - /** * Adjustment used when calculating the maximum data value. */ @@ -3175,10 +3173,7 @@ export const LogarithmicScale: ChartComponent & { new (cfg: AnyObject): LogarithmicScale; }; -export type TimeScaleOptions = CartesianScaleOptions & { - min: string | number; - max: string | number; - +export type TimeScaleOptions = Omit & { suggestedMin: string | number; suggestedMax: string | number; /** diff --git a/types/tests/scales/time_string_max.ts b/types/tests/scales/time_string_max.ts new file mode 100644 index 00000000000..530b1c548e3 --- /dev/null +++ b/types/tests/scales/time_string_max.ts @@ -0,0 +1,30 @@ +import { Chart } from '../../index.esm'; + +const chart = new Chart('id', { + type: 'line', + data: { + datasets: [ + { + label: 'Pie', + data: [ + ], + borderColor: '#000000', + backgroundColor: '#00FF00' + } + ] + }, + options: { + scales: { + x: { + type: 'time', + min: '2021-01-01', + max: '2021-12-01' + }, + y: { + type: 'linear', + min: 0, + max: 10 + } + } + } +});