react-pivottable
react-pivottable copied to clipboard
react-pivottable in typescript-Could not find a declaration file for module 'react-pivottable/PivotTableUI'.
Hi,
I got the following error when I was trying to import PivotTableUI into my typescript file.
Could not find a declaration file for module 'react-pivottable/PivotTableUI'. 'c:/projects/myProjects/node_modules/react-pivottable/PivotTableUI.js' implicitly has an 'any' type.
Try npm i --save-dev @types/react-pivottable
if it exists or add a new declaration (.d.ts) file containing declare module 'react-pivottable/PivotTableUI';
ts(7016)
Seems it's caused by the lack of declaration file of PivotTableUI?Or just use it in js instead of typescript...
Hey! So I'm just starting to use this for fun (making a web-app to make a more powerful representation of Mint), and am using React with Typescript. I'm having the same issue.
The cause of this is that there are no Type declarations since this is a pure javascript library. There are type declarations for react-plotly.js
if you're using that package for the extra renderer, and that can be installed via npm i @types/react-plotly.js --save-dev
.
Unfortunately, doing a search in the ts types db doesn't yield any results, and I don't see anyone making a definitions file elsewhere either. This is maintained with this Github page, and searching for this repo I don't find anything (or for the original pivottable.js).
I did come across this issue on the pivottable.js project, where someone provided a typescript definition file, but it looks like no one ever contributed that to the DefinitlyTyped repo.
All of that to say:
This is still usable without a type definition file, it's just more cumbersome. All you have do is declare your own definitions file in your project, and declare whatever you need as any
.
Eventually, I do think that I'll be creating a type definitions file for this library, but at the moment I'll be taking the any
approach.
Its a pity that TS is still not used on this project
I'd say feel free to create the typings file for it - I still have yet to make one as I'm still using the any
approach. I haven't had the need to make anything more than that.