Reputation: 89
I am trying to use a 'scroll to top' component:
import ScrollUpButton from 'react-scroll-up-button';
It seems that because I am using Typescript, it doesn't accept this import for some reason. I get an unusual error, but no idea what to do with it (the first recommendation for Typing does not work):
Could not find a declaration file for module 'react-scroll-up-button'. '/../react-scroll-up-button/dist/react-scroll-up-button.js' implicitly has an 'any' type.
Try `npm install @types/react-scroll-up-button` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-scroll-up-button';`
Upvotes: 0
Views: 273
Reputation: 181
You could create a typedef file(react-scroll-up-button.d.ts
) inside the folder where you have your .ts
file with the next content:
declare module 'foo';
This will create a basic type definition, so your ScrollUpButton
will be of type any
. You could extend the type def if you want, but this should be enough to clean up the error.
Upvotes: 1