I am getting this weird typescript error in IDE on line 16 (<Line ...) when converting my react es6 comp to typescript. Its a chart component where I am using react-chartjs-2.
Property 'type' is missing in type '{ data: { labels: string[]; datasets: { label: string; data: string[]; }[]; }; height: number; width: number; options: { maintainAspectRatio: boolean; scales: { yAxes: { ticks: { beginAtZero: boolean; }; }[]; }; legend: { ...; }; }; }' but required in type 'Props'.
import React from "react";
import { Line, defaults } from "react-chartjs-2";
defaults.plugins.tooltip.enabled = true;
defaults.plugins.legend.position = "bottom";
interface Props {
currencyValues: string[],
dateList: string[],
}
const LineGraph = ({ currencyValues, dateList }: Props) => {
return (
<div className="graphContainer">
{currencyValues.length ? (
<Line
data={{
labels: [...dateList],
datasets: [
{
label: "Historical Dates",
data: [...currencyValues],
},
],
}}
height={400}
width={600}
options={{
maintainAspectRatio: false,
scales: {
yAxes: [
{
ticks: {
beginAtZero: true,
},
},
],
},
legend: {
labels: {
fontSize: 25,
},
},
}}
/>
) : null}
</div>
);
};
export default LineGraph;