Chartjs-TypeScript does not accept points with x being a string for Line chart of time type

1👍

My bad, the error was coming from something else, in my case
it was coming from this declaration using the React useState hook:

const [chartData, setChartData] = useState<ChartData<"line">>({
    datasets: [],
});

Which was incomplete, causing a type inconsistency in my code.
I fixed it by writing:

const [chartData, setChartData] = useState<ChartData<"line", StatPointDto[]>>({
    datasets: [],
});

Leave a comment