react-pivottable icon indicating copy to clipboard operation
react-pivottable copied to clipboard

react-pivottable in typescript-Could not find a declaration file for module 'react-pivottable/PivotTableUI'.

Open normanwss opened this issue 4 years ago • 3 comments

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...

normanwss avatar Jan 04 '21 07:01 normanwss

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.

alex-polosky avatar Feb 19 '21 02:02 alex-polosky

Its a pity that TS is still not used on this project

Lonli-Lokli avatar Jun 21 '21 09:06 Lonli-Lokli

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.

alex-polosky avatar Jun 21 '21 13:06 alex-polosky