I'm encountering an issue while utilizing the Chart.js library in my Angular application with Typescript. The error message I'm receiving is as follows:
Error: Object literal may only specify known properties, and 'stepSize' does not exist in type 'TickOptions'.
Upon inspecting the TickOptions
interface, it appears that the property is indeed missing there. However, it is present in another interface that extends TickOptions
, namely the LinearTickOptions
interface:
interface LinearTickOptions extends TickOptions {
maxTicksLimit?: number;
stepSize?: number;
suggestedMin?: number;
suggestedMax?: number;
}
Is there a way to instruct Typescript to reference the LinearTickOptions
interface instead of TickOptions
?
The section of code triggering the error is shown below:
new Chart(this.clientsPerMonthElement.nativeElement, {
type: 'line',
data: {
labels,
datasets: [{
data,
label: 'Clientes no mês',
backgroundColor: 'transparent',
borderColor: lineColor,
borderWidth: 2,
pointBackgroundColor: lineColor,
pointRadius: 4,
}],
},
options: {
legend: {
display: false,
},
scales: {
yAxes: [{
ticks: {
beginAtZero: true,
stepSize: 1, // This is where the error occurs
},
}],
},
},
});