My callback method is throwing an error
TS2322:... Type `string | number` is not assignable to type `number`. Type `string` is not assignable to type `number`.
Any suggestions on how to resolve this issue?
import { ChartOptions } from "chart.js"
const options: ChartOptions = {
responsive: true,
interaction: {
mode: 'index',
intersect: false,
},
elements: {
point: {
radius: 1,
pointStyle: 'circle',
hoverRadius: 2,
hoverBorderWidth: 3,
},
line: {
fill: true,
},
},
scales: {
x: {
ticks: {
// <--------- the error occurs here --------->
callback(val: number, index: number): string {
return index % 2 === 0 ? this.getLabelForValue(val) : '';
},
color: 'red',
maxRotation: 0,
minRotation: 0,
}
}
}
},