Search code examples
reactjstypescriptchartstypesreact-chartjs

React-typescript chart.js error 'type' is missing in type


i am a learning typescript, recently moved from react, i am using chart js for some graph in my react-typescript project and from few hours i am getting this error

Property 'type' is missing in type '{ data: { labels: string[]; datasets: { label: string; data: number[]; fill: boolean; backgroundColor: string; borderColor: string; }[]; }; options: { scales: { yAxes: { ticks: { beginAtZero: boolean; }; }[]; }; }; }' but required in type 'Props' enter image description here

it would be great if anyone could help me out here THank you


Solution

  • Even though react-chartjs-2 is not expecting an type props for Line component and its value is assign to line by default, The interface used has the type props as required. Please find the interface here

    Please pass the type prop to the link tag.

    <line type='line' data={data} />