You must be logged in to post your query.
Home › Forums › Chart Support › ReactJSCharts + Typescript
Tagged: typescript
I’m working on a project with React and Typescript. I’m running into an error that’s stemming from the import of the CanvasJSReact chart import (import CanvasJSReact from ‘@canvasjs/react-charts’) . The error shows up as “TS7016: Could not find a declaration file for module ‘@canvasjs/react-charts’. ‘C:/…/../…/…/node_modules/@canvasjs/react-charts/canvasjs.react.js’ implicitly has an ‘any’ type.” When I run npm start, the website runs and the graph is displayed, but the error message does not go away.
Does this package include a type declaration for typescript uses?
I did npm install for both @canvasjs and for @canvasjs/react-charts, but still getting the same error. Would love some help.
@emin500,
React charts seem to be working fine with typescript. Please take a look at this Stackblitz code for a working example.
If you are still facing issue, kindly create a sample project reproducing the issue you are facing and share it with us over Onedrive / Google-Drive, so that we can run the sample locally at our end to understand the scenario better and help you out.
__ Sachin Bisht Team CanvasJS
Even the Stackblitz shows a typescript error: Cannot find module '@canvasjs/react-charts' or its corresponding type declarations.
Cannot find module '@canvasjs/react-charts' or its corresponding type declarations.
if you hover over ‘@canvasjs/react-charts’ in the import statement
@gojukeboxgmail-com,
We don’t have CanvasJS React Charts TypeScript definition as of now. However, charts seems to work fine with React TypeScript as-well. You can ignore the corresponding error in Stackblitz by adding // @ts-ignore above the import statement as shown in the code-snippet below.
// @ts-ignore
// @ts-ignore import CanvasJSReact from '@canvasjs/react-charts';
You must be logged in to reply to this topic. Login/Register