diff --git a/src/types/index.d.ts b/src/types/index.d.ts index 14461328a92..0656d4d01a6 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -1508,7 +1508,7 @@ export declare const Ticks: { * @param ticks the list of ticks being converted * @return string representation of the tickValue parameter */ - numeric(tickValue: number, index: number, ticks: { value: number }[]): string; + numeric(this: Scale, tickValue: number, index: number, ticks: { value: number }[]): string; /** * Formatter for logarithmic ticks * @param tickValue the value to be formatted @@ -1516,7 +1516,7 @@ export declare const Ticks: { * @param ticks the list of ticks being converted * @return string representation of the tickValue parameter */ - logarithmic(tickValue: number, index: number, ticks: { value: number }[]): string; + logarithmic(this: Scale, tickValue: number, index: number, ticks: { value: number }[]): string; }; }; diff --git a/test/types/ticks/ticks.ts b/test/types/ticks/ticks.ts new file mode 100644 index 00000000000..a5a9e28bef8 --- /dev/null +++ b/test/types/ticks/ticks.ts @@ -0,0 +1,15 @@ +import { Chart, Ticks } from '../../../src/types.js'; + +// @ts-expect-error The 'this' context... is not assignable to method's 'this' of type 'Scale'. +Ticks.formatters.numeric(0, 0, [{ value: 0 }]); + +const chart = new Chart('test', { + type: 'line', + data: { + datasets: [{ + data: [{ x: 1, y: 1 }] + }] + }, +}); + +Ticks.formatters.numeric.call(chart.scales.x, 0, 0, [{ value: 0 }]);