Closed
Description
Expected Behavior
These lines of Typescript code, which compiled fine in 3.0.0-beta.10, should also compile in beta.11 (I haven't found any documented breaking change documenting those):
const chartOptions: ChartConfiguration<'bar'> = {
type: 'bar',
// irrelevant properties omitted
options: {
plugins: {
tooltip: {
callbacks: {
// error here because dataPoint doesn't exist anymore
label: context => context.dataset.label + ': ' + formatNumber(context.dataPoint.y)
}
}
},
scales: {
y: {
ticks: {
// error here because the tick value is now typed as unknown
callback: (value: number) => formatNumber(value)
}
}
}
}
};
Current Behavior
They don't compile anymore.
Possible Solution
I've had to change them to
const chartOptions: ChartConfiguration<'bar'> = {
type: 'bar',
// irrelevant properties omitted
options: {
plugins: {
tooltip: {
callbacks: {
label: context =>
context.dataset.label +
': ' +
formatNumber(context.dataset.data[context.dataIndex] as number)
// dataPoint was easier to use than the above, and its `y` value was typed as number, whereas context.dataset.data[context.dataIndex] as number is typed as unknown
}
}
},
scales: {
y: {
ticks: {
callback: (value) => formatNumber(value as number)
}
}
}
}
};