I installed and imported react-tilt following this page, but got below message and unable to use it. I am not sure what the message suggest. Does somebody know how to fix it?
Asked
Active
Viewed 316 times
0

Patrick Roberts
- 49,224
- 10
- 102
- 153

David Z
- 6,641
- 11
- 50
- 101
-
1You imported a JavaScript file into a TypeScript file and the TypeScript compiler is telling you it has no idea what the types are for that JavaScript file. – Patrick Roberts Jul 26 '20 at 17:50
-
Why isn't there issue for other modules but Tilt? – David Z Jul 26 '20 at 17:52
-
Because the other modules export a declaration file along with their JavaScript. `react-tilt` is not a TypeScript module. – Patrick Roberts Jul 26 '20 at 17:54
-
Thanks, any suggestions to fix it? – David Z Jul 26 '20 at 17:55
-
1"add a new declaration (.d.ts) file containing `declare module 'react-tilt';`". The directions are pretty clear. – Patrick Roberts Jul 26 '20 at 17:55
-
Thanks you very much! – David Z Jul 26 '20 at 17:57
-
Does this answer your question? [Could not find a declaration file for module 'module-name'. '/path/to/module-name.js' implicitly has an 'any' type](https://stackoverflow.com/questions/41292559/could-not-find-a-declaration-file-for-module-module-name-path-to-module-nam) – Patrick Roberts Jul 26 '20 at 17:57
1 Answers
0
VS Code tell you to add manually the declaration for this module.
You can do it by creating a new file called index.d.ts
inside the module (/node_modules/react-tilt
)
and add the following line inside it :
declare module 'react-tilt';
A way to do it faster, just copy paste the following line in your terminal.
If you're using bash or zsh :
cd ./node_modules/react-tilt && touch index.d.ts && echo "declare module 'react-tilt';" > index.d.ts
If you're using windows terminal :
cd ./node_modules/react-tilt && echo declare module 'react-tilt'; > index.d.ts

Konixy
- 41
- 5